Created
August 31, 2011 14:32
-
-
Save cbaldin/1183683 to your computer and use it in GitHub Desktop.
Comparação arquivos texto .txt MD5
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
InputStream is = new FileInputStream("Nome do arquivo 1"); | |
InputStream is1 = new FileInputStream("Nome do arquivo 2"); | |
try { | |
MessageDigest oi = MessageDigest.getInstance("MD5"); | |
is = new DigestInputStream((InputStream)is, oi); | |
byte[] bites = oi.digest(); | |
MessageDigest oi2 = MessageDigest.getInstance("MD5"); | |
is2 = new DigestInputStream((InputStream)is2, oi2); | |
byte[] bites2 = oi2.digest(); | |
Assert.assertTrue(bites.equals(bites2)); | |
} catch (NoSuchAlgorithmException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} finally { | |
is.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment