Here you can find the source of sha1sum(InputStream file)
public static String sha1sum(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 sha1sum(InputStream file) { InputStream in = file;/*from w w w . j av a2 s .c o m*/ try { MessageDigest digest = MessageDigest.getInstance("SHA1"); byte[] buffer = new byte[8192]; int read = 0; while ((read = in.read(buffer)) > 0) { digest.update(buffer, 0, read); } byte[] sha1sum = digest.digest(); BigInteger bigInt = new BigInteger(1, sha1sum); 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); } } } }