iaik.utils
Class TracedInputStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.FilterInputStream
|
+--iaik.utils.TracedInputStream
- public class TracedInputStream
- extends java.io.FilterInputStream
A TracedInputStream traces all the data which is read from an InputStream.
Method 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:
// the InputStream containing a DER encoded ASN.1 object:
InputStream is;
TracedInputStream tis = new TracedInputStream(is);
// read and decode the next encoded ASN.1 object from is:
ASN1Object asn1_obj = DerCoder.decode(tis);
// get the encoded bytes which have been read from is:
byte[] raw = tis.getTracedData();
...
| Fields inherited from class java.io.FilterInputStream |
in |
|
Constructor Summary |
TracedInputStream(java.io.InputStream is)
Constructs a TracedInputStream from the InputStream which should be traced. |
|
Method Summary |
byte[] |
getTracedData()
Returns the data which have been read from the InputStream. |
int |
read()
Reads the next byte from this stream and returns it as int value between 0 and 255. |
int |
read(byte[] b,
int off,
int len)
Reads up to len bytes from this stream into the given byte array. |
| 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 |
TracedInputStream
public TracedInputStream(java.io.InputStream is)
- Constructs a TracedInputStream from the InputStream which should be traced.
- Parameters:
is - - the input stream.
read
public int read(byte[] b,
int off,
int len)
throws java.io.IOException
- Reads up to
len bytes from this stream into the given byte array.
- Overrides:
- read in class java.io.FilterInputStream
- Parameters:
b - the byte array to which to read the dataoff - the offset indicating the start position within the destination byte
array, to which the data is writtenlen - the maximum number of bytes to be read- Returns:
- the number of bytes actually read from this stream, or -1 if the end
of the stream already has been reached
- Throws:
- java.io.IOException - if an I/O error occurs
read
public int read()
throws java.io.IOException
- Reads the next byte from this stream and returns it as int value between 0 and 255.
- Overrides:
- read in class java.io.FilterInputStream
- Returns:
- the next byte as int value between 0 and 255, or -1 if the end of the
stream already has been reached
- Throws:
- java.io.IOException - if an I/O error occurs
getTracedData
public byte[] getTracedData()
- Returns the data which have been read from the InputStream.
- Returns:
- the data which have been read from the InputStream.