private static byte[] calculateMd5sum(final File file) throws IOException {
  try (final FileInputStream inputStream=new FileInputStream(file)){
    final MessageDigest md5=MessageDigest.getInstance("md5");
    final byte[] buffer=new byte[1024];
    int read=inputStream.read(buffer);
    while (read > -1) {
      md5.update(buffer,0,read);
      read=inputStream.read(buffer);
    }
    return md5.digest();
  }
 catch (  NoSuchAlgorithmException nsae) {
    throw new IllegalArgumentException(nsae);
  }
}

private static byte [ ] calculateMd5sum ( final File file ) throws IOException { try ( final FileInputStream inputStream = new FileInputStream ( file ) ) { final MessageDigest md5 = MessageDigest . getInstance ( "md5" ) ; final byte [ ] buffer = new byte [ 1024 ] ; int read = inputStream . read ( buffer ) ; while ( read > - 1 ) { md5 . update ( buffer , 0 , read ) ; read = inputStream . read ( buffer ) ; } return md5 . digest ( ) ; } catch ( NoSuchAlgorithmException nsae ) { throw new IllegalArgumentException ( nsae ) ; } }
calculates an md5 sum of the specified file .
