Methods Summary |
---|
public java.security.MessageDigest | getMessageDigest()Returns the message digest for this stream.
return digest;
|
public void | on(boolean on)Enables or disables the digest function (default is on).
isOn = on;
|
public void | setMessageDigest(java.security.MessageDigest digest)Sets the message digest which this stream will use.
this.digest = digest;
|
public java.lang.String | toString()Returns a string containing a concise, human-readable description of this
{@code DigestOutputStream} including the digest.
return super.toString() + ", " + digest.toString() + //$NON-NLS-1$
(isOn ? ", is on" : ", is off"); //$NON-NLS-1$ //$NON-NLS-2$
|
public void | write(int b)Writes the specified {@code int} to the stream. Updates the digest if
this function is {@link #on(boolean)}.
// update digest only if digest functionality is on
if (isOn) {
digest.update((byte)b);
}
// write the byte
out.write(b);
|
public void | write(byte[] b, int off, int len)Writes {@code len} bytes into the stream, starting from the specified
offset. Updates the digest if this function is {@link #on(boolean)}.
// update digest only if digest functionality is on
if (isOn) {
digest.update(b, off, len);
}
// write len bytes
out.write(b, off, len);
|