public class TracedInputStream
extends java.io.FilterInputStream
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(); ...
Constructor and Description |
---|
TracedInputStream(java.io.InputStream is)
Constructs a TracedInputStream from the InputStream which should be traced.
|
TracedInputStream(java.io.InputStream is,
int initialSize)
Constructs a TracedInputStream from the InputStream which should be traced.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getTracedData()
Returns the data which have been read from the InputStream.
|
byte[] |
getTracedData(boolean reset)
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. |
public TracedInputStream(java.io.InputStream is)
is
- - the input stream.public TracedInputStream(java.io.InputStream is, int initialSize)
is
- - the input stream.initialSize
- the initial size (in bytes) of the internal bufferpublic int read(byte[] b, int off, int len) throws java.io.IOException
len
bytes from this stream into the given byte array.
read
in class java.io.FilterInputStream
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 readjava.io.IOException
- if an I/O error occurspublic int read() throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
- if an I/O error occurspublic byte[] getTracedData()
public byte[] getTracedData(boolean reset)
reset
- whether to reset the internal buffer to start tracing
anew; and further call of getTracedData
will return the data traced from now on