Class Overview
DigestOutputStream
is a FilterOutputStream
which maintains an
associated message digest.
Summary
Public Methods |
MessageDigest
|
getMessageDigest()
Returns the message digest for this stream.
|
void
|
on(boolean on)
Enables or disables the digest function (default is on).
|
void
|
setMessageDigest(MessageDigest digest)
Sets the message digest which this stream will use.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
DigestOutputStream including the digest.
|
void
|
write(byte[] b, int off, int len)
Writes len bytes into the stream, starting from the specified
offset.
|
void
|
write(int b)
Writes the specified int to the stream.
|
[Expand]
Inherited Methods |
From class
java.io.FilterOutputStream
void
|
close()
Closes this stream.
|
void
|
flush()
Ensures that all pending data is sent out to the target stream.
|
void
|
write(byte[] buffer, int offset, int length)
Writes count bytes from the byte array buffer starting at
offset to the target stream.
|
void
|
write(int oneByte)
Writes one byte to the target stream.
|
|
From class
java.io.OutputStream
void
|
close()
Closes this stream.
|
void
|
flush()
Flushes this stream.
|
void
|
write(byte[] buffer, int offset, int count)
Writes count bytes from the byte array buffer starting at
position offset to this stream.
|
void
|
write(byte[] buffer)
Equivalent to write(buffer, 0, buffer.length) .
|
abstract
void
|
write(int oneByte)
Writes a single byte to this stream.
|
|
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals(Object o)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
final
void
|
wait(long millis, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long millis)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
|
From interface
java.io.Closeable
abstract
void
|
close()
Closes the object and release any system resources it holds.
|
|
From interface
java.io.Flushable
abstract
void
|
flush()
Flushes the object by writing out any buffered data to the underlying
output.
|
|
From interface
java.lang.AutoCloseable
abstract
void
|
close()
Closes the object and release any system resources it holds.
|
|
Fields
The message digest for this stream.
Public Constructors
Constructs a new instance of this DigestOutputStream
, using the
given stream
and the digest
.
Parameters
stream
| the output stream. |
digest
| the message digest.
|
Public Methods
public
MessageDigest
getMessageDigest
()
Returns the message digest for this stream.
Returns
- the message digest for this stream.
public
void
on
(boolean on)
Enables or disables the digest function (default is on).
Parameters
on
| true if the digest should be computed, false
otherwise. |
public
void
setMessageDigest
(MessageDigest digest)
Sets the message digest which this stream will use.
Parameters
digest
| the message digest which this stream will use.
|
public
String
toString
()
Returns a string containing a concise, human-readable description of this
DigestOutputStream
including the digest.
Returns
- a printable representation for this
DigestOutputStream
.
public
void
write
(byte[] b, int off, int len)
Writes len
bytes into the stream, starting from the specified
offset. Updates the digest if this function is on(boolean)
.
Parameters
b
| the buffer to write to. |
off
| the index of the first byte in b to write. |
len
| the number of bytes in b to write. |
Throws
IOException
| if writing to the stream causes an IOException .
|
public
void
write
(int b)
Writes the specified int
to the stream. Updates the digest if
this function is on(boolean)
.
Parameters
b
| the byte to be written. |
Throws
IOException
| if writing to the stream causes a IOException
|