Skip to content

Commit e951342

Browse files
TestUtils: use try-with-resources instead of deprecated IOUtils#closeQuietly
(side-effect: close #28)
1 parent 31c0d3a commit e951342

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

src/test/java/org/apache/commons/io/testtools/TestUtils.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import junit.framework.AssertionFailedError;
2020
import org.apache.commons.io.FileUtils;
21-
import org.apache.commons.io.IOUtils;
2221
import org.apache.commons.io.output.ByteArrayOutputStream;
2322

2423
import java.io.*;
@@ -72,13 +71,10 @@ public static void createLineBasedFile(final File file, final String[] data) thr
7271
if (file.getParentFile() != null && !file.getParentFile().exists()) {
7372
throw new IOException("Cannot create file " + file + " as the parent directory does not exist");
7473
}
75-
final PrintWriter output = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
76-
try {
74+
try (final PrintWriter output = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"))) {
7775
for (final String element : data) {
7876
output.println(element);
7977
}
80-
} finally {
81-
IOUtils.closeQuietly(output);
8278
}
8379
}
8480

0 commit comments

Comments
 (0)