From 6870022916139c3fcacef9f57d053ccb03f0c3c3 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Mon, 15 Oct 2012 13:15:09 +0000 Subject: [PATCH] The class implements Closeable. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1398278 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/java/org/apache/commons/csv/CSVPrinter.java | 9 ++++++++- src/test/java/org/apache/commons/csv/CSVPrinterTest.java | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/csv/CSVPrinter.java b/src/main/java/org/apache/commons/csv/CSVPrinter.java index c9c9055f..b976c53d 100644 --- a/src/main/java/org/apache/commons/csv/CSVPrinter.java +++ b/src/main/java/org/apache/commons/csv/CSVPrinter.java @@ -23,6 +23,7 @@ import static org.apache.commons.csv.Constants.EMPTY; import static org.apache.commons.csv.Constants.LF; import static org.apache.commons.csv.Constants.SP; +import java.io.Closeable; import java.io.Flushable; import java.io.IOException; import java.sql.ResultSet; @@ -33,7 +34,7 @@ import java.sql.SQLException; * * @version $Id: $ */ -public class CSVPrinter implements Flushable { +public class CSVPrinter implements Flushable, Closeable { /** The place that the values get written. */ private final Appendable out; @@ -387,4 +388,10 @@ public class CSVPrinter implements Flushable { println(); } } + + public void close() throws IOException { + if (out instanceof Closeable) { + ((Closeable) out).close(); + } + } } diff --git a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java index a72b5aa0..8f108894 100644 --- a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java +++ b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java @@ -77,6 +77,7 @@ public class CSVPrinterTest { } printer.flush(); + printer.close(); final String result = sw.toString(); // System.out.println("### :" + printable(result));