public static boolean filesDiffer(File first, File second) throws Exception {
if (first.length() != second.length()) {
return true;
}
InputStream firstStream = new FileInputStream(first);
InputStream secondStream = new FileInputStream(second);
try {
for (int i = 0; i < first.length(); i++) {
if (firstStream.read() != secondStream.read()) {
return false;
}
}
return true;
}
finally {
try {
firstStream.close();
}
finally {
secondStream.close();
}
}
}
|