DigestOutputStream
open class DigestOutputStream : FilterOutputStream
kotlin.Any | |||
↳ | java.io.OutputStream | ||
↳ | java.io.FilterOutputStream | ||
↳ | java.security.DigestOutputStream |
A transparent stream that updates the associated message digest using the bits going through the stream.
To complete the message digest computation, call one of the digest
methods on the associated message digest after your calls to one of this digest output stream's #write(int) methods.
It is possible to turn this stream on or off (see on
). When it is on, a call to one of the write
methods results in an update on the message digest. But when it is off, the message digest is not updated. The default is for the stream to be on.
Summary
Public constructors | |
---|---|
DigestOutputStream(stream: OutputStream!, digest: MessageDigest!) Creates a digest output stream, using the specified output stream and message digest. |
Public methods | |
---|---|
open MessageDigest! |
Returns the message digest associated with this stream. |
open Unit |
Turns the digest function on or off. |
open Unit |
setMessageDigest(digest: MessageDigest!) Associates the specified message digest with this stream. |
open String |
toString() Prints a string representation of this digest output stream and its associated message digest object. |
open Unit |
Updates the message digest (if the digest function is on) using the specified byte, and in any case writes the byte to the output stream. |
open Unit |
Updates the message digest (if the digest function is on) using the specified subarray, and in any case writes the subarray to the output stream. |
Inherited functions | |
---|---|
Properties | |
---|---|
MessageDigest! |
The message digest associated with this stream. |
Inherited properties | |
---|---|
Public constructors
DigestOutputStream
DigestOutputStream(
stream: OutputStream!,
digest: MessageDigest!)
Creates a digest output stream, using the specified output stream and message digest.
Parameters | |
---|---|
stream |
OutputStream!: the output stream. |
digest |
MessageDigest!: the message digest to associate with this stream. |
Public methods
getMessageDigest
open fun getMessageDigest(): MessageDigest!
Returns the message digest associated with this stream.
Return | |
---|---|
MessageDigest! |
the message digest associated with this stream. |
on
open fun on(on: Boolean): Unit
Turns the digest function on or off. The default is on. When it is on, a call to one of the write
methods results in an update on the message digest. But when it is off, the message digest is not updated.
Parameters | |
---|---|
on |
Boolean: true to turn the digest function on, false to turn it off. |
setMessageDigest
open fun setMessageDigest(digest: MessageDigest!): Unit
Associates the specified message digest with this stream.
Parameters | |
---|---|
digest |
MessageDigest!: the message digest to be associated with this stream. |
See Also
toString
open fun toString(): String
Prints a string representation of this digest output stream and its associated message digest object.
Return | |
---|---|
String |
a string representation of the object. |
write
open fun write(b: Int): Unit
Updates the message digest (if the digest function is on) using the specified byte, and in any case writes the byte to the output stream. That is, if the digest function is on (see on
), this method calls update
on the message digest associated with this stream, passing it the byte b
. This method then writes the byte to the output stream, blocking until the byte is actually written.
Parameters | |
---|---|
b |
Int: the byte to be used for updating and writing to the output stream. |
Exceptions | |
---|---|
java.io.IOException |
if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed. |
java.io.IOException |
if an I/O error occurs. |
write
open fun write(
b: ByteArray!,
off: Int,
len: Int
): Unit
Updates the message digest (if the digest function is on) using the specified subarray, and in any case writes the subarray to the output stream. That is, if the digest function is on (see on
), this method calls update
on the message digest associated with this stream, passing it the subarray specifications. This method then writes the subarray bytes to the output stream, blocking until the bytes are actually written.
Parameters | |
---|---|
b |
ByteArray!: the array containing the subarray to be used for updating and writing to the output stream. |
off |
Int: the offset into b of the first byte to be updated and written. |
len |
Int: the number of bytes of data to be updated and written from b , starting at offset off . |
Exceptions | |
---|---|
java.io.IOException |
if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed. |
java.io.IOException |
if an I/O error occurs. |
Properties
digest
protected var digest: MessageDigest!
The message digest associated with this stream.