code: public static String md5sum(InputStream input) throws IOException {
          InputStream in = new BufferedInputStream(input);
          try {
              MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
              DigestInputStream digestInputStream = new DigestInputStream(in, digest);
              while(digestInputStream.read() >= 0) {
              }
              OutputStream md5out = new ByteArrayOutputStream();
              md5out.write(digest.digest());
              return md5out.toString();
          }
          catch(NoSuchAlgorithmException e) {
              throw new IllegalStateException("MD5 algorithm is not available: " + e.getMessage());
          }
          finally {
              in.close();
          }
      }
docs: Computes the MD5 value of the input stream
  
  @param input
  @return
  @throws IOException
  @throws IllegalStateException