Package com.google.common.hash
Class HashingInputStream
-
-
-
- com.google.common.hash.HashingInputStream
-
-
-
- All Implemented Interfaces:
,
@Beta public final class HashingInputStream extends
An that maintains a hash of the data read from it.- Since:
- 16.0
- Author:
- Qian Huang
-
-
Constructor Summary
Constructors Constructor Description HashingInputStream(HashFunction hashFunction, in)
Creates an input stream that hashes using the givenHashFunction
and delegates all data read from it to the underlying .
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HashCode
hash()
Returns theHashCode
based on the data read from this stream.void
mark(int readlimit)
mark() is not supported for HashingInputStreamboolean
markSupported()
mark() is not supported for HashingInputStreamint
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.
-
-
-
Constructor Detail
-
HashingInputStream
public HashingInputStream(HashFunction hashFunction, in)
Creates an input stream that hashes using the givenHashFunction
and delegates all data read from it to the underlying .The should not be read from before or after the hand-off.
-
-
Method Detail
-
read
public int read() throws
Reads the next byte of data from the underlying input stream and updates the hasher with the byte read.- Overrides:
in class
- Returns:
- the next byte of data, or
-1
if the end of the stream is reached. - Throws:
- if an I/O error occurs.
- See Also:
-
read
public int read(byte[] bytes, int off, int len) throws
Reads the specified bytes of data from the underlying input stream and updates the hasher with the bytes read.- Overrides:
in class
- Parameters:
bytes
- the buffer into which the data is read.off
- the start offset in the destination arrayb
len
- the maximum number of bytes read.- Returns:
- the total number of bytes read into the buffer, or
-1
if there is no more data because the end of the stream has been reached. - Throws:
- if an I/O error occurs.
- See Also:
-
markSupported
public boolean markSupported()
mark() is not supported for HashingInputStream- Overrides:
in class
- Returns:
false
always- See Also:
- , ,
-
mark
public void mark(int readlimit)
mark() is not supported for HashingInputStream- Overrides:
in class
- Parameters:
readlimit
- the maximum limit of bytes that can be read before the mark position becomes invalid.- See Also:
- ,
-
reset
public void reset() throws
reset() is not supported for HashingInputStream.- Overrides:
in class
- Throws:
- this operation is not supported
- See Also:
- ,
-
-