Merge pull request #445 from sigee/use-nio

Use NIO instead of old IO.
This commit is contained in:
Gary Gregory 2024-07-11 14:46:34 -04:00 committed by GitHub
commit a4980da8ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 4 deletions

View File

@ -20,11 +20,9 @@ package org.apache.commons.csv;
import static org.apache.commons.io.IOUtils.EOF;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Serializable;
import java.io.StringWriter;
@ -2069,8 +2067,7 @@ public final class CSVFormat implements Serializable {
*/
@SuppressWarnings("resource")
public CSVPrinter print(final File out, final Charset charset) throws IOException {
// The writer will be closed when close() is called.
return new CSVPrinter(new OutputStreamWriter(new FileOutputStream(out), charset), this);
return print(out.toPath(), charset);
}
private void print(final InputStream inputStream, final Appendable out, final boolean newRecord) throws IOException {