The class implements Closeable.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1398278 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2012-10-15 13:15:09 +00:00
parent 4aee321abb
commit 6870022916
2 changed files with 9 additions and 1 deletions

View File

@ -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.LF;
import static org.apache.commons.csv.Constants.SP; import static org.apache.commons.csv.Constants.SP;
import java.io.Closeable;
import java.io.Flushable; import java.io.Flushable;
import java.io.IOException; import java.io.IOException;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -33,7 +34,7 @@ import java.sql.SQLException;
* *
* @version $Id: $ * @version $Id: $
*/ */
public class CSVPrinter implements Flushable { public class CSVPrinter implements Flushable, Closeable {
/** The place that the values get written. */ /** The place that the values get written. */
private final Appendable out; private final Appendable out;
@ -387,4 +388,10 @@ public class CSVPrinter implements Flushable {
println(); println();
} }
} }
public void close() throws IOException {
if (out instanceof Closeable) {
((Closeable) out).close();
}
}
} }

View File

@ -77,6 +77,7 @@ public class CSVPrinterTest {
} }
printer.flush(); printer.flush();
printer.close();
final String result = sw.toString(); final String result = sw.toString();
// System.out.println("### :" + printable(result)); // System.out.println("### :" + printable(result));