Skip to content

Instantly share code, notes, and snippets.

@x5gtrn
Created February 16, 2010 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save x5gtrn/305406 to your computer and use it in GitHub Desktop.
Save x5gtrn/305406 to your computer and use it in GitHub Desktop.
public boolean isEquals(File file1, File file2) {
FileInputStream fis1 = null;
FileInputStream fis2 = null;
try {
byte[] ba1 = new byte[(int) file1.length()];
byte[] ba2 = new byte[(int) file2.length()];
fis1 = new FileInputStream(file1);
fis1.read(ba1);
fis2 = new FileInputStream(file2);
fis2.read(ba2);
return Arrays.equals(ba1, ba2);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fis1 != null) {
fis1.close();
}
if (fis2 != null) {
fis2.close();
}
} catch (Exception e) {
//ignore
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment