Skip navigation links

Oracle Security Developer Tools Crypto Java API Reference
11g (11.1.1)

E10668-02


oracle.security.crypto.core
Class DigestInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by oracle.security.crypto.core.DigestInputStream

All Implemented Interfaces:
java.io.Closeable

public class DigestInputStream
extends java.io.FilterInputStream

An input stream that keeps a message digest of the bytes going through it.

The method computeCurrent() computes and returns the current digest.


Field Summary
protected  MessageDigest messageDigest
          The message digest used by this stream.

 

Fields inherited from class java.io.FilterInputStream
in

 

Constructor Summary
DigestInputStream(java.io.InputStream is, MessageDigest md)
          Create a new DigestInputStream with specified InputStream and Message Digest.

 

Method Summary
 byte[] computeCurrent()
          Compute and return the current digest.
 MessageDigest getMessageDigest()
          Return the message digest for this stream.
 int read()
          Read one byte of data.
 int read(byte[] b, int off, int len)
          Reads into an array of bytes.
 void setMessageDigest(MessageDigest md)
          Set the message digest for this stream.

 

Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

messageDigest

protected MessageDigest messageDigest
The message digest used by this stream.

Constructor Detail

DigestInputStream

public DigestInputStream(java.io.InputStream is,
                         MessageDigest md)
Create a new DigestInputStream with specified InputStream and Message Digest.

Method Detail

read

public int read()
         throws java.io.IOException
Read one byte of data. Blocks if no data is available. The message digest is updated.
Overrides:
read in class java.io.FilterInputStream
Returns:
the byte read, or -1 if end of stream reached.
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Reads into an array of bytes. Blocks if no data is available. Updates the message digest.
Overrides:
read in class java.io.FilterInputStream
Parameters:
b - the buffer which the data is read into
off - start offset of data
len - maximum number of bytes read
Returns:
the number of bytes read, or -1 if end of stream reached.
Throws:
java.io.IOException

computeCurrent

public byte[] computeCurrent()
Compute and return the current digest.

getMessageDigest

public MessageDigest getMessageDigest()
Return the message digest for this stream.

setMessageDigest

public void setMessageDigest(MessageDigest md)
Set the message digest for this stream.

Skip navigation links

Oracle Security Developer Tools Crypto Java API Reference
11g (11.1.1)

E10668-02


Copyright © 2005, 2009, Oracle. All rights reserved.