|
34 | 34 | import java.nio.charset.Charset; |
35 | 35 | import java.nio.charset.StandardCharsets; |
36 | 36 | import java.nio.file.Files; |
| 37 | +import java.nio.file.OpenOption; |
37 | 38 | import java.nio.file.Path; |
38 | 39 | import java.nio.file.StandardCopyOption; |
39 | 40 | import java.util.ArrayList; |
@@ -386,6 +387,7 @@ private static void cleanDirectoryOnExit(final File directory) throws IOExceptio |
386 | 387 | * @return true if the content of the files are equal or they both don't |
387 | 388 | * exist, false otherwise |
388 | 389 | * @throws IOException in case of an I/O error |
| 390 | + * @see org.apache.commons.io.file.PathUtils#fileContentEquals(Path,Path,OpenOption...) |
389 | 391 | */ |
390 | 392 | public static boolean contentEquals(final File file1, final File file2) throws IOException { |
391 | 393 | if (file1 == null && file2 == null) { |
@@ -471,12 +473,8 @@ public static boolean contentEqualsIgnoreEOL(final File file1, final File file2, |
471 | 473 | return true; |
472 | 474 | } |
473 | 475 |
|
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))) { |
480 | 478 | return IOUtils.contentEqualsIgnoreEOL(input1, input2); |
481 | 479 | } |
482 | 480 | } |
|
0 commit comments