public static Sha256Hash createFrom(InputStream is) throws IOException {
  try {
    MessageDigest digest=getMessageDigest();
    DigestInputStream digestInputStream=new DigestInputStream(is,digest);
    ByteStreams.copy(digestInputStream,ByteStreams.nullOutputStream());
    digestInputStream.close();
    return createFrom(digest);
  }
  finally {
    try {
      is.close();
    }
 catch (    IOException e) {
    }
  }
}

public static Sha256Hash createFrom ( InputStream is ) throws IOException { try { MessageDigest digest = getMessageDigest ( ) ; DigestInputStream digestInputStream = new DigestInputStream ( is , digest ) ; ByteStreams . copy ( digestInputStream , ByteStreams . nullOutputStream ( ) ) ; digestInputStream . close ( ) ; return createFrom ( digest ) ; } finally { try { is . close ( ) ; } catch ( IOException e ) { } } }
this method will read all the bytes in the stream and digest them . it will attempt to close the stream as well .
