@Beta public final class HashingInputStream extends FilterInputStream
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, skip
public HashingInputStream(HashFunction hashFunction, InputStream in)
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
read
in class FilterInputStream
IOException
public int read(byte[] bytes, int off, int len) throws IOException
read
in class FilterInputStream
IOException
@CheckReturnValue public boolean markSupported()
markSupported
in class FilterInputStream
false
alwayspublic void mark(int readlimit)
mark
in class FilterInputStream
public void reset() throws IOException
reset
in class FilterInputStream
IOException
- this operation is not supported@CheckReturnValue public HashCode hash()
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.Copyright © 2010-2015. All Rights Reserved.