From 58849db64a9ae8de89a75f8f97924283c057734d Mon Sep 17 00:00:00 2001 From: Sigee Date: Thu, 11 Jul 2024 16:49:19 +0200 Subject: [PATCH] Use NIO instead of old io. --- src/main/java/org/apache/commons/csv/CSVFormat.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/org/apache/commons/csv/CSVFormat.java b/src/main/java/org/apache/commons/csv/CSVFormat.java index 0dd50031..af5c02cb 100644 --- a/src/main/java/org/apache/commons/csv/CSVFormat.java +++ b/src/main/java/org/apache/commons/csv/CSVFormat.java @@ -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 {