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:
parent
4aee321abb
commit
6870022916
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ public class CSVPrinterTest {
|
|||
}
|
||||
|
||||
printer.flush();
|
||||
printer.close();
|
||||
final String result = sw.toString();
|
||||
// System.out.println("### :" + printable(result));
|
||||
|
||||
|
|
Loading…
Reference in New Issue