Created
February 16, 2010 09:15
-
-
Save x5gtrn/305406 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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