private boolean digestStream(InputStream is, Metadata metadata) throws IOException {
        byte[] digestBytes;
        MessageDigest messageDigest = newMessageDigest();

        updateDigest(messageDigest, is, metadata);
        digestBytes = messageDigest.digest();

        if (is instanceof BoundedInputStream) {
            if (((BoundedInputStream) is).hasHitBound()) {
                return false;
            }
        }
        metadata.set(getMetadataKey(), encoder.encode(digestBytes));
        return true;
    }
@param is       input stream to read from
@param metadata metadata for reporting the digest
@return whether or not this finished the input stream
@throws IOException
tika-core/src/main/java/org/apache/tika/parser/digest/InputStreamDigester.java