@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.
@CanIgnoreReturnValue public int read() throws IOException
read
in class FilterInputStream
-1
if the end of the
stream is reached.IOException
- if an I/O error occurs.FilterInputStream.in
@CanIgnoreReturnValue public int read(byte[] bytes, int off, int len) throws IOException
read
in class FilterInputStream
bytes
- the buffer into which the data is read.off
- the start offset in the destination array b
len
- the maximum number of bytes read.-1
if there is no more data because the end of
the stream has been reached.IOException
- if an I/O error occurs.FilterInputStream.in
public boolean markSupported()
markSupported
in class FilterInputStream
false
alwaysFilterInputStream.in
,
InputStream.mark(int)
,
InputStream.reset()
public void mark(int readlimit)
mark
in class FilterInputStream
readlimit
- the maximum limit of bytes that can be read before
the mark position becomes invalid.FilterInputStream.in
,
FilterInputStream.reset()
public void reset() throws IOException
reset
in class FilterInputStream
IOException
- this operation is not supportedFilterInputStream.in
,
FilterInputStream.mark(int)
Copyright © 2010–2020. All rights reserved.