Build 1.0_r1(from source)

java.security
Class DigestOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by java.security.DigestOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class DigestOutputStream
extends FilterOutputStream


Field Summary
protected  MessageDigest digest
           
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
DigestOutputStream(OutputStream stream, MessageDigest digest)
           
 
Method Summary
 MessageDigest getMessageDigest()
          Returns the MessageDigest which the receiver uses when computing the hash.
 void on(boolean on)
          Enables or disables the digest function (default is on).
 void setMessageDigest(MessageDigest digest)
          Sets the MessageDigest which the receiver will use when computing the hash.
 String toString()
          Returns a string containing a concise, human-readable description of the receiver.
 void write(byte[] b, int off, int len)
          Writes count bytes from the byte array buffer starting at offset to this FilterOutputStream.
 void write(int b)
          Writes the specified byte oneByte to this FilterOutputStream.
 
Methods inherited from class java.io.FilterOutputStream
close, flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

digest

protected MessageDigest digest
Constructor Detail

DigestOutputStream

public DigestOutputStream(OutputStream stream,
                          MessageDigest digest)
Method Detail

getMessageDigest

public MessageDigest getMessageDigest()
Returns the MessageDigest which the receiver uses when computing the hash.

Returns:
MessageDigest the digest the receiver uses when computing the hash.

setMessageDigest

public void setMessageDigest(MessageDigest digest)
Sets the MessageDigest which the receiver will use when computing the hash.

Parameters:
digest - MessageDigest the digest to use when computing the hash.
See Also:
MessageDigest, on(boolean)

write

public void write(int b)
           throws IOException
Description copied from class: FilterOutputStream
Writes the specified byte oneByte to this FilterOutputStream. Only the low order byte of oneByte is written. This implementation writes the byte to the target OutputStream.

Overrides:
write in class FilterOutputStream
Parameters:
b - the byte to be written
Throws:
IOException - If an error occurs attempting to write to this FilterOutputStream.

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Description copied from class: FilterOutputStream
Writes count bytes from the byte array buffer starting at offset to this FilterOutputStream. This implementation writes the buffer to the target OutputStream.

Overrides:
write in class FilterOutputStream
Parameters:
b - the buffer to be written
off - offset in buffer to get bytes
len - number of bytes in buffer to write
Throws:
IOException - If an error occurs attempting to write to this FilterOutputStream.

on

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

Parameters:
on - boolean true if the digest should be computed, and false otherwise.
See Also:
MessageDigest

toString

public String toString()
Returns a string containing a concise, human-readable description of the receiver.

Overrides:
toString in class Object
Returns:
String a printable representation for the receiver.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature