All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class iaik.utils.TracedInputStream

java.lang.Object
   |
   +----java.io.InputStream
           |
           +----java.io.FilterInputStream
                   |
                   +----iaik.utils.TracedInputStream

public synchronized class TracedInputStream
extends FilterInputStream
A TracedInputStream traces all the data which is read from an InputStream. Method @see getTracedData() returns an array, which contains the data read from an InputStream. A TracedInputStream is useful when a decoder reads from an InputStream and the encoded data is also needed. For example:
 InputStream is;                    // the InputStream containing a DER encoded ASN.1 object
 BerCoder coder = new BerCoder();
 TracedInputStream tis = new TracedInputStream(is);
 coder.decode(tis);                 // read the next encoded ASN.1 object from is
 byte[] raw = tis.getTracedData();  // returns the encoded bytes which have been read from is
 ...
 


Constructor Index

 o TracedInputStream(InputStream)
Constructs a TracedInputStream from the InputStream which should be traced.

Method Index

 o getTracedData()
Returns the data which have been read from the InputStream.
 o read()
Reads the next byte of data from this input stream.
 o read(byte[], int, int)
Reads up to len bytes of data from this input stream into an array of bytes.

Constructors

 o TracedInputStream
 public TracedInputStream(InputStream is)
Constructs a TracedInputStream from the InputStream which should be traced.

Parameters:
is - - the input stream.

Methods

 o read
 public int read(byte b[],
                 int off,
                 int len) throws IOException
Reads up to len bytes of data from this input stream into an array of bytes. This method blocks until some input is available. If the first argument is null, up to len bytes are read and discarded.

Parameters:
b - - the buffer into which the data is read.
off - - the start offset of the data.
len - - the maximum number of bytes read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws: IOException
if an I/O error occurs.
Overrides:
read in class FilterInputStream
 o read
 public int read() throws IOException
Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255 . If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws: IOException
if an I/O error occurs.
Overrides:
read in class FilterInputStream
 o getTracedData
 public byte[] getTracedData()
Returns the data which have been read from the InputStream.

Returns:
the data which have been read from the InputStream.

All Packages  Class Hierarchy  This Package  Previous  Next  Index