to top
Android APIs
public class

DigestOutputStream

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

Class Overview

DigestOutputStream is a FilterOutputStream which maintains an associated message digest.

Summary

Fields
protected MessageDigest digest The message digest for this stream.
[Expand]
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.
[Expand]
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

Fields

protected MessageDigest digest

Since: API Level 1

The message digest for this stream.

Public Constructors

public DigestOutputStream (OutputStream stream, MessageDigest digest)

Since: API Level 1

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 ()

Since: API Level 1

Returns the message digest for this stream.

Returns
  • the message digest for this stream.

public void on (boolean on)

Since: API Level 1

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

Parameters
on true if the digest should be computed, false otherwise.
See Also

public void setMessageDigest (MessageDigest digest)

Since: API Level 1

Sets the message digest which this stream will use.

Parameters
digest the message digest which this stream will use.

public String toString ()

Since: API Level 1

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)

Since: API Level 1

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)

Since: API Level 1

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