|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.InputStream
java.io.FilterInputStream
java.security.DigestInputStream
public class DigestInputStream
DigestInputStream is a class that ties an InputStream with a MessageDigest. The Message Digest is used by the class to update it self as bytes are read from the InputStream. The updating to the digest depends on the on flag which is set to true by default to tell the class to update the data in the message digest.
| Field Summary | |
|---|---|
protected MessageDigest |
digest
The message digest for the DigestInputStream |
| Fields inherited from class java.io.FilterInputStream |
|---|
in |
| Constructor Summary | |
|---|---|
DigestInputStream(InputStream stream,
MessageDigest digest)
Constructs a new DigestInputStream. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.io.FilterInputStream |
|---|
available, close, mark, markSupported, read, reset, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected MessageDigest digest
| Constructor Detail |
|---|
public DigestInputStream(InputStream stream,
MessageDigest digest)
stream - An InputStream to associate this stream withdigest - A MessageDigest to hash the stream with| Method Detail |
|---|
public MessageDigest getMessageDigest()
public void setMessageDigest(MessageDigest digest)
digest - A MessageDigest to associate with this stream
public int read()
throws IOException
read in class FilterInputStreamIOException - if an IO error occurs in the underlying input stream,
this error is thrown
public 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 read
IOException - 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)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||