@Beta public final class HashingInputStream extends FilterInputStream
An InputStream that maintains a hash of the data read from it.
in| Constructor and Description |
|---|
HashingInputStream(HashFunction hashFunction,
InputStream in)
Creates an input stream that hashes using the given
HashFunction and delegates all data read from it to the underlying InputStream. |
| Modifier and Type | Method and Description |
|---|---|
HashCode |
hash()
Returns the
HashCode based on the data read from this stream. |
void |
mark(int readlimit)
mark() is not supported for HashingInputStream
|
boolean |
markSupported()
mark() is not supported for HashingInputStream
|
int |
read()
Reads the next byte of data from the underlying input stream and updates the hasher with the byte read.
|
int |
read(byte[] bytes,
int off,
int len)
Reads the specified bytes of data from the underlying input stream and updates the hasher with the bytes read.
|
void |
reset()
reset() is not supported for HashingInputStream.
|
available, close, read, skippublic HashingInputStream(HashFunction hashFunction, InputStream in)
Creates an input stream that hashes using the given HashFunction and delegates all data read from it to the underlying InputStream.
The InputStream should not be read from before or after the hand-off.
public int read()
throws IOException
Reads the next byte of data from the underlying input stream and updates the hasher with the byte read.
read in class FilterInputStreamIOExceptionpublic int read(byte[] bytes,
int off,
int len)
throws IOException
Reads the specified bytes of data from the underlying input stream and updates the hasher with the bytes read.
read in class FilterInputStreamIOException@CheckReturnValue public boolean markSupported()
mark() is not supported for HashingInputStream
markSupported in class FilterInputStreamfalse alwayspublic void mark(int readlimit)
mark() is not supported for HashingInputStream
mark in class FilterInputStreampublic void reset()
throws IOException
reset() is not supported for HashingInputStream.
reset in class FilterInputStreamIOException - this operation is not supported@CheckReturnValue public HashCode hash()
Returns the HashCode based on the data read from this stream. The result is unspecified if this method is called more than once on the same instance.