Skip to content

Most visited

Recently visited

navigation
Added in API level 1

DigestOutputStream

public class DigestOutputStream
extends FilterOutputStream

java.lang.Object
   ↳ java.io.OutputStream
     ↳ java.io.FilterOutputStream
       ↳ java.security.DigestOutputStream


DigestOutputStream is a FilterOutputStream which maintains an associated message digest.

Summary

Fields

protected MessageDigest digest

The message digest for this stream.

Inherited fields

From class java.io.FilterOutputStream

Public constructors

DigestOutputStream(OutputStream stream, MessageDigest digest)

Constructs a new instance of this DigestOutputStream, using the given stream and the digest.

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.

Inherited methods

From class java.io.FilterOutputStream
From class java.io.OutputStream
From class java.lang.Object
From interface java.io.Closeable
From interface java.io.Flushable
From interface java.lang.AutoCloseable

Fields

digest

Added in API level 1
MessageDigest digest

The message digest for this stream.

Public constructors

DigestOutputStream

Added in API level 1
DigestOutputStream (OutputStream stream, 
                MessageDigest digest)

Constructs a new instance of this DigestOutputStream, using the given stream and the digest.

Parameters
stream OutputStream: the output stream.
digest MessageDigest: the message digest.

Public methods

getMessageDigest

Added in API level 1
MessageDigest getMessageDigest ()

Returns the message digest for this stream.

Returns
MessageDigest the message digest for this stream.

on

Added in API level 1
void on (boolean on)

Enables or disables the digest function (default is on).

Parameters
on boolean: true if the digest should be computed, false otherwise.

See also:

setMessageDigest

Added in API level 1
void setMessageDigest (MessageDigest digest)

Sets the message digest which this stream will use.

Parameters
digest MessageDigest: the message digest which this stream will use.

toString

Added in API level 1
String toString ()

Returns a string containing a concise, human-readable description of this DigestOutputStream including the digest.

Returns
String a printable representation for this DigestOutputStream.

write

Added in API level 1
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 byte: the buffer to write to.
off int: the index of the first byte in b to write.
len int: the number of bytes in b to write.
Throws
IOException if writing to the stream causes an IOException.

write

Added in API level 1
void write (int b)

Writes the specified int to the stream. Updates the digest if this function is on(boolean).

Parameters
b int: the byte to be written.
Throws
IOException if writing to the stream causes a IOException
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.