in src/main/java/org/apache/commons/io/FileUtils.java [463:494]
public static boolean contentEqualsIgnoreEOL(final File file1, final File file2, final String charsetName)
throws IOException {
if (file1 == null && file2 == null) {
return true;
}
if (file1 == null || file2 == null) {
return false;
}
final boolean file1Exists = file1.exists();
if (file1Exists != file2.exists()) {
return false;
}
if (!file1Exists) {
// two not existing files are equal
return true;
}
checkFileExists(file1, "file1");
checkFileExists(file2, "file2");
if (file1.getCanonicalFile().equals(file2.getCanonicalFile())) {
// same file
return true;
}
final Charset charset = Charsets.toCharset(charsetName);
try (Reader input1 = new InputStreamReader(Files.newInputStream(file1.toPath()), charset);
Reader input2 = new InputStreamReader(Files.newInputStream(file2.toPath()), charset)) {
return IOUtils.contentEqualsIgnoreEOL(input1, input2);
}
}