public class DigestInputStream extends FilterInputStream
| Modifier and Type | Field and Description |
|---|---|
protected MessageDigest |
digest
The message digest for the DigestInputStream
|
in| Constructor and Description |
|---|
DigestInputStream(InputStream stream,
MessageDigest digest)
Constructs a new DigestInputStream.
|
| Modifier and Type | Method and Description |
|---|---|
MessageDigest |
getMessageDigest()
Returns the MessageDigest associated with this DigestInputStream
|
void |
on(boolean on)
Sets the flag specifing if this DigestInputStream updates the
digest in the write() methods.
|
int |
read()
Reads a byte from the input stream and updates the digest.
|
int |
read(byte[] b,
int off,
int len)
Reads bytes from the input stream and updates the digest.
|
void |
setMessageDigest(MessageDigest digest)
Sets the current MessageDigest to current parameter
|
String |
toString()
Converts the input stream and underlying message digest to a string.
|
available, close, mark, markSupported, read, reset, skipprotected MessageDigest digest
public DigestInputStream(InputStream stream, MessageDigest digest)
stream - An InputStream to associate this stream withdigest - A MessageDigest to hash the stream withpublic MessageDigest getMessageDigest()
public void setMessageDigest(MessageDigest digest)
digest - A MessageDigest to associate with this streampublic int read() throws IOException
read in class FilterInputStreamIOException - if an IO error occurs in the underlying input stream,
this error is thrownpublic int read(byte[] b, int off, int len) throws IOException
read in class FilterInputStreamb - a byte array to store the data from the input streamoff - an offset to start at in the arraylen - length of data to readIOException - if an IO error occurs in the underlying input stream,
this error is thrownpublic void on(boolean on)
on - True means it digests stream, false means it does notpublic String toString()
toString in class ObjectObject.getClass(),
Object.hashCode(),
Class.getName(),
Integer.toHexString(int)