in src/main/java/org/apache/commons/io/FileUtils.java [411:442]
public static boolean contentEquals(final File file1, final File file2) 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;
}
checkIsFile(file1, "file1");
checkIsFile(file2, "file2");
if (file1.length() != file2.length()) {
// lengths differ, cannot be equal
return false;
}
if (file1.getCanonicalFile().equals(file2.getCanonicalFile())) {
// same file
return true;
}
return PathUtils.fileContentEquals(file1.toPath(), file2.toPath());
}