@Beta public final class HashingOutputStream extends FilterOutputStream
OutputStream
that maintains a hash of the data written to it.out
Constructor and Description |
---|
HashingOutputStream(HashFunction hashFunction,
OutputStream out)
Creates an output stream that hashes using the given
HashFunction , and forwards all
data written to it to the underlying OutputStream . |
Modifier and Type | Method and Description |
---|---|
void |
close() |
HashCode |
hash()
Returns the
HashCode based on the data written to this stream. |
void |
write(byte[] bytes,
int off,
int len) |
void |
write(int b) |
flush, write
public HashingOutputStream(HashFunction hashFunction, 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 IOException
write
in class FilterOutputStream
IOException
public void write(byte[] bytes, int off, int len) throws IOException
write
in class FilterOutputStream
IOException
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 IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class FilterOutputStream
IOException
Copyright © 2010-2017. All Rights Reserved.