static String md5(final InputStream in,final int bufferLength) throws IOException {
  final byte[] buffer=new byte[bufferLength];
  try {
    final MessageDigest md=MessageDigest.getInstance("MD5");
    final DigestInputStream dis=new DigestInputStream(in,md);
    while (dis.read(buffer) != -1) {
    }
    final byte[] digest=md.digest();
    return digestToString(digest);
  }
 catch (  final NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
  }
}

static String md5 ( final InputStream in , final int bufferLength ) throws IOException { final byte [ ] buffer = new byte [ bufferLength ] ; try { final MessageDigest md = MessageDigest . getInstance ( "MD5" ) ; final DigestInputStream dis = new DigestInputStream ( in , md ) ; while ( dis . read ( buffer ) != - 1 ) { } final byte [ ] digest = md . digest ( ) ; return digestToString ( digest ) ; } catch ( final NoSuchAlgorithmException e ) { throw new RuntimeException ( e ) ; } }
read all of the input stream and return it ' s md5 digest .
