Package com.google.common.hash
Class HashingOutputStream
- java.lang.Object
- 
- java.io.OutputStream
- 
- java.io.FilterOutputStream
- 
- com.google.common.hash.HashingOutputStream
 
 
 
- 
- All Implemented Interfaces:
- java.io.Closeable,- java.io.Flushable,- java.lang.AutoCloseable
 
 @Beta public final class HashingOutputStream extends java.io.FilterOutputStream AnOutputStreamthat maintains a hash of the data written to it.- Since:
- 16.0
- Author:
- Nick Piepmeier
 
- 
- 
Constructor SummaryConstructors Constructor Description HashingOutputStream(HashFunction hashFunction, java.io.OutputStream out)Creates an output stream that hashes using the givenHashFunction, and forwards all data written to it to the underlyingOutputStream.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()HashCodehash()Returns theHashCodebased on the data written to this stream.voidwrite(byte[] bytes, int off, int len)voidwrite(int b)
 
- 
- 
- 
Constructor Detail- 
HashingOutputStreampublic HashingOutputStream(HashFunction hashFunction, java.io.OutputStream out) Creates an output stream that hashes using the givenHashFunction, and forwards all data written to it to the underlyingOutputStream.The OutputStreamshould not be written to before or after the hand-off.
 
- 
 - 
Method Detail- 
writepublic void write(int b) throws java.io.IOException - Overrides:
- writein class- java.io.FilterOutputStream
- Throws:
- java.io.IOException
 
 - 
writepublic void write(byte[] bytes, int off, int len) throws java.io.IOException - Overrides:
- writein class- java.io.FilterOutputStream
- Throws:
- java.io.IOException
 
 - 
hashpublic HashCode hash() Returns theHashCodebased on the data written to this stream. The result is unspecified if this method is called more than once on the same instance.
 - 
closepublic void close() throws java.io.IOException - Specified by:
- closein interface- java.lang.AutoCloseable
- Specified by:
- closein interface- java.io.Closeable
- Overrides:
- closein class- java.io.FilterOutputStream
- Throws:
- java.io.IOException
 
 
- 
 
-