@Beta public final class HashingOutputStream extends java.io.FilterOutputStream
OutputStream that maintains a hash of the data written to it.| Constructor and Description |
|---|
HashingOutputStream(HashFunction hashFunction,
java.io.OutputStream out)
Creates an output stream that hashes using the given
HashFunction, and forwards all
data written to it to the underlying OutputStream. |
public HashingOutputStream(HashFunction hashFunction, java.io.OutputStream out)
HashFunction, and forwards all
data written to it to the underlying OutputStream.
The OutputStream should not be written to before or after the hand-off.
public void write(int b)
throws java.io.IOException
write in class java.io.FilterOutputStreamjava.io.IOExceptionpublic void write(byte[] bytes,
int off,
int len)
throws java.io.IOException
write in class java.io.FilterOutputStreamjava.io.IOException@CheckReturnValue public HashCode hash()
HashCode based on the data written to this stream. The result is
unspecified if this method is called more than once on the same instance.public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.FilterOutputStreamjava.io.IOException