commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pascalschumac...@apache.org
Subject commons-io git commit: TestUtils: use try-with-resources instead of deprecated IOUtils#closeQuietly
Date Wed, 23 Nov 2016 19:24:42 GMT
Repository: commons-io
Updated Branches:
  refs/heads/master 31c0d3a8e -> e95134229


TestUtils: use try-with-resources instead of deprecated IOUtils#closeQuietly

(side-effect: close #28)


Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/e9513422
Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/e9513422
Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/e9513422

Branch: refs/heads/master
Commit: e95134229b9066aa2f1d312a53f5a670d271dbfa
Parents: 31c0d3a
Author: pascalschumacher <pascalschumacher@gmx.net>
Authored: Wed Nov 23 20:24:29 2016 +0100
Committer: pascalschumacher <pascalschumacher@gmx.net>
Committed: Wed Nov 23 20:24:29 2016 +0100

----------------------------------------------------------------------
 src/test/java/org/apache/commons/io/testtools/TestUtils.java | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-io/blob/e9513422/src/test/java/org/apache/commons/io/testtools/TestUtils.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/io/testtools/TestUtils.java b/src/test/java/org/apache/commons/io/testtools/TestUtils.java
index fcdbbc8..d8b5737 100644
--- a/src/test/java/org/apache/commons/io/testtools/TestUtils.java
+++ b/src/test/java/org/apache/commons/io/testtools/TestUtils.java
@@ -18,7 +18,6 @@ package org.apache.commons.io.testtools;
 
 import junit.framework.AssertionFailedError;
 import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.output.ByteArrayOutputStream;
 
 import java.io.*;
@@ -72,13 +71,10 @@ public abstract class TestUtils {
         if (file.getParentFile() != null && !file.getParentFile().exists()) {
             throw new IOException("Cannot create file " + file + " as the parent directory
does not exist");
         }
-        final PrintWriter output = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file),
"UTF-8"));
-        try {
+        try (final PrintWriter output = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file),
"UTF-8"))) {
             for (final String element : data) {
                 output.println(element);
             }
-        } finally {
-            IOUtils.closeQuietly(output);
         }
     }
 


Mime
View raw message