public class DigestWriter extends FilterWriter
Modifier and Type | Field and Description |
---|---|
protected MessageDigest |
digest
The message digest associated with this stream.
|
out
Constructor and Description |
---|
DigestWriter(Writer writer,
MessageDigest digest)
Creates a digest writer, using the specified writer and message digest.
|
Modifier and Type | Method and Description |
---|---|
MessageDigest |
getMessageDigest()
Returns the message digest associated with this writer.
|
void |
on(boolean on)
Turns the digest function on or off.
|
void |
setMessageDigest(MessageDigest digest)
Associates the specified message digest with this writer.
|
String |
toString()
Prints a string representation of this digest output stream and its associated message digest object.
|
void |
write(char[] cbuf,
int off,
int len) |
void |
write(int c) |
void |
write(String str,
int off,
int len) |
close, flush
protected MessageDigest digest
public DigestWriter(Writer writer, MessageDigest digest)
writer
- the writer.digest
- the message digest to associate with this writer.public MessageDigest getMessageDigest()
setMessageDigest(java.security.MessageDigest)
public void setMessageDigest(MessageDigest digest)
digest
- the message digest to be associated with this writer.getMessageDigest()
public void write(int c) throws IOException
write
in class FilterWriter
IOException
public void write(char[] cbuf, int off, int len) throws IOException
write
in class FilterWriter
IOException
public void write(String str, int off, int len) throws IOException
write
in class FilterWriter
IOException
public void on(boolean on)
write
methods results in an update on the message digest. But when it is off, the message digest is not updated.on
- true to turn the digest function on, false to turn it off.Copyright (c) 2011, 2012 Eike Stepper (Berlin, Germany) and others.