public static String getMD5(File file) {
    DigestInputStream stream = null;
    try
    {
      stream = new DigestInputStream(new FileInputStream(file), MessageDigest.getInstance("MD5"));
      byte[] buffer = new byte[65536];

      int read;
      read = stream.read(buffer);
      while (read >= 1)
        read = stream.read(buffer);
    }
    catch (Exception ignored)
    {
      return null;
    } finally {
      closeSilently(stream);
    }

    return String.format("%1$032x", new Object[] { new BigInteger(1, stream.getMessageDigest().digest()) });
  }