Here you can find the source of md5sum(InputStream file)
public static String md5sum(InputStream file)
//package com.java2s; import java.io.IOException; import java.io.InputStream; import java.math.BigInteger; import java.security.MessageDigest; public class Main { public static String md5sum(InputStream file) { InputStream in = file;/*from www . j ava 2 s .c o m*/ try { MessageDigest digest = MessageDigest.getInstance("MD5"); byte[] buffer = new byte[8192]; int read = 0; while ((read = in.read(buffer)) > 0) { digest.update(buffer, 0, read); } byte[] md5sum = digest.digest(); BigInteger bigInt = new BigInteger(1, md5sum); return bigInt.toString(16); } catch (Exception e) { throw new RuntimeException("Unable to process file for MD5", e); } finally { if (in != null) try { in.close(); } catch (IOException e) { throw new RuntimeException("Unable to close input stream for MD5 calculation", e); } } } }