Class HashingInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
com.google.common.hash.HashingInputStream
- All Implemented Interfaces:
- Closeable,- AutoCloseable
An 
InputStream that maintains a hash of the data read from it.- Since:
- 16.0
- Author:
- Qian Huang
- 
Field SummaryFields inherited from class java.io.FilterInputStreamin
- 
Constructor SummaryConstructorsConstructorDescriptionHashingInputStream(HashFunction hashFunction, InputStream in) Creates an input stream that hashes using the givenHashFunctionand delegates all data read from it to the underlyingInputStream.
- 
Method SummaryModifier and TypeMethodDescriptionhash()Returns theHashCodebased on the data read from this stream.voidmark(int readlimit) mark() is not supported for HashingInputStreambooleanmark() is not supported for HashingInputStreamintread()Reads the next byte of data from the underlying input stream and updates the hasher with the byte read.intread(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.voidreset()reset() is not supported for HashingInputStream.Methods inherited from class java.io.FilterInputStreamavailable, close, read, skipMethods inherited from class java.io.InputStreamnullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
- 
Constructor Details- 
HashingInputStreamCreates an input stream that hashes using the givenHashFunctionand delegates all data read from it to the underlyingInputStream.The InputStreamshould not be read from before or after the hand-off.
 
- 
- 
Method Details- 
readReads the next byte of data from the underlying input stream and updates the hasher with the byte read.- Overrides:
- readin class- FilterInputStream
- Throws:
- IOException
 
- 
readReads the specified bytes of data from the underlying input stream and updates the hasher with the bytes read.- Overrides:
- readin class- FilterInputStream
- Throws:
- IOException
 
- 
markSupportedpublic boolean markSupported()mark() is not supported for HashingInputStream- Overrides:
- markSupportedin class- FilterInputStream
- Returns:
- falsealways
 
- 
markpublic void mark(int readlimit) mark() is not supported for HashingInputStream- Overrides:
- markin class- FilterInputStream
 
- 
resetreset() is not supported for HashingInputStream.- Overrides:
- resetin class- FilterInputStream
- Throws:
- IOException- this operation is not supported
 
- 
hash
 
-