commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject [commons-io] branch master updated: Clean ups.
Date Mon, 25 Nov 2019 20:02:23 GMT
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git


The following commit(s) were added to refs/heads/master by this push:
     new ef5b7a3  Clean ups.
ef5b7a3 is described below

commit ef5b7a36875ec0c5691be77015b3a54515ef08a3
Author: Gary Gregory <gardgregory@gmail.com>
AuthorDate: Mon Nov 25 15:02:19 2019 -0500

    Clean ups.
---
 src/main/java/org/apache/commons/io/FileUtils.java | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/io/FileUtils.java b/src/main/java/org/apache/commons/io/FileUtils.java
index 4a2aa27..05d42ca 100644
--- a/src/main/java/org/apache/commons/io/FileUtils.java
+++ b/src/main/java/org/apache/commons/io/FileUtils.java
@@ -34,6 +34,7 @@ import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
+import java.nio.file.OpenOption;
 import java.nio.file.Path;
 import java.nio.file.StandardCopyOption;
 import java.util.ArrayList;
@@ -386,6 +387,7 @@ public class FileUtils {
      * @return true if the content of the files are equal or they both don't
      * exist, false otherwise
      * @throws IOException in case of an I/O error
+     * @see org.apache.commons.io.file.PathUtils#fileContentEquals(Path,Path,OpenOption...)
      */
     public static boolean contentEquals(final File file1, final File file2) throws IOException
{
         if (file1 == null && file2 == null) {
@@ -471,12 +473,8 @@ public class FileUtils {
             return true;
         }
 
-        try (Reader input1 = charsetName == null
-                                 ? new InputStreamReader(new FileInputStream(file1), Charset.defaultCharset())
-                                 : new InputStreamReader(new FileInputStream(file1), charsetName);
-             Reader input2 = charsetName == null
-                                 ? new InputStreamReader(new FileInputStream(file2), Charset.defaultCharset())
-                                 : new InputStreamReader(new FileInputStream(file2), charsetName))
{
+        try (Reader input1 = new InputStreamReader(new FileInputStream(file1), Charsets.toCharset(charsetName));
+             Reader input2 = new InputStreamReader(new FileInputStream(file2), Charsets.toCharset(charsetName)))
{
             return IOUtils.contentEqualsIgnoreEOL(input1, input2);
         }
     }


Mime
View raw message