Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
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
From interface java.lang.AutoCloseable

Fields

protected MessageDigest digest

Added in API level 1

The message digest for this stream.

Public Constructors

public DigestOutputStream ( OutputStream stream, MessageDigest digest)

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

Added in API level 1

Returns the message digest for this stream.

Returns
  • the message digest for this stream.

public void on (boolean on)

Added in API level 1

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)

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

Added in 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)

Added in 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)

Added in 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