Skip to content

Commit ef5b7a3

Browse files
author
Gary Gregory
committed
Clean ups.
1 parent b0a9ab1 commit ef5b7a3

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/main/java/org/apache/commons/io/FileUtils.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.nio.charset.Charset;
3535
import java.nio.charset.StandardCharsets;
3636
import java.nio.file.Files;
37+
import java.nio.file.OpenOption;
3738
import java.nio.file.Path;
3839
import java.nio.file.StandardCopyOption;
3940
import java.util.ArrayList;
@@ -386,6 +387,7 @@ private static void cleanDirectoryOnExit(final File directory) throws IOExceptio
386387
* @return true if the content of the files are equal or they both don't
387388
* exist, false otherwise
388389
* @throws IOException in case of an I/O error
390+
* @see org.apache.commons.io.file.PathUtils#fileContentEquals(Path,Path,OpenOption...)
389391
*/
390392
public static boolean contentEquals(final File file1, final File file2) throws IOException {
391393
if (file1 == null && file2 == null) {
@@ -471,12 +473,8 @@ public static boolean contentEqualsIgnoreEOL(final File file1, final File file2,
471473
return true;
472474
}
473475

474-
try (Reader input1 = charsetName == null
475-
? new InputStreamReader(new FileInputStream(file1), Charset.defaultCharset())
476-
: new InputStreamReader(new FileInputStream(file1), charsetName);
477-
Reader input2 = charsetName == null
478-
? new InputStreamReader(new FileInputStream(file2), Charset.defaultCharset())
479-
: new InputStreamReader(new FileInputStream(file2), charsetName)) {
476+
try (Reader input1 = new InputStreamReader(new FileInputStream(file1), Charsets.toCharset(charsetName));
477+
Reader input2 = new InputStreamReader(new FileInputStream(file2), Charsets.toCharset(charsetName))) {
480478
return IOUtils.contentEqualsIgnoreEOL(input1, input2);
481479
}
482480
}

0 commit comments

Comments
 (0)