Here you can find the source of computeMD5Hash(InputStream is)
public static byte[] computeMD5Hash(InputStream is) throws NoSuchAlgorithmException, IOException
//package com.java2s; //License from project: Apache License import java.io.*; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static byte[] computeMD5Hash(InputStream is) throws NoSuchAlgorithmException, IOException { MessageDigest messageDigest = MessageDigest.getInstance("MD5"); byte[] buffer = new byte[1024 * 1024]; int bytesRead; while ((bytesRead = is.read(buffer, 0, buffer.length)) != -1) { messageDigest.update(buffer, 0, bytesRead); }//from www . ja v a 2s .co m return messageDigest.digest(); } }