Skip to content

Instantly share code, notes, and snippets.

@cbaldin
Created August 31, 2011 14:32
Show Gist options
  • Save cbaldin/1183683 to your computer and use it in GitHub Desktop.
Save cbaldin/1183683 to your computer and use it in GitHub Desktop.
Comparação arquivos texto .txt MD5
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