com.sun.faban.driver.transport.util
Class TimedInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
com.sun.faban.driver.transport.util.TimedInputStream
- All Implemented Interfaces:
- Closeable
public class TimedInputStream
- extends FilterInputStream
A pass-through input stream that records the time of the input.
Note that the client-side time recording for reads is
always after the read happens.
- Author:
- Akara Sucharitakul
Constructor Summary |
TimedInputStream(InputStream in)
Creates a FilterInputStream
by assigning the argument in
to the field this.in so as
to remember it for later use. |
Method Summary |
int |
read()
Reads the next byte of data from this input stream. |
int |
read(byte[] b)
Reads up to byte.length bytes of data from this
input stream into an array of bytes. |
int |
read(byte[] b,
int off,
int len)
Reads up to len bytes of data from this input stream
into an array of bytes. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TimedInputStream
public TimedInputStream(InputStream in)
- Creates a
FilterInputStream
by assigning the argument in
to the field this.in
so as
to remember it for later use.
- Parameters:
in
- the underlying input stream, or null
if
this instance is to be created without an underlying stream.
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.
This method
simply performs in.read()
and returns the result.
- Overrides:
read
in class FilterInputStream
- Returns:
- the next byte of data, or
-1
if the end of the
stream is reached.
- Throws:
IOException
- if an I/O error occurs.- See Also:
FilterInputStream.in
read
public int read(byte[] b)
throws IOException
- Reads up to
byte.length
bytes of data from this
input stream into an array of bytes. This method blocks until some
input is available.
This method simply performs the call
read(b, 0, b.length)
and returns
the result. It is important that it does
not do in.read(b)
instead;
certain subclasses of FilterInputStream
depend on the implementation strategy actually
used.
- Overrides:
read
in class FilterInputStream
- Parameters:
b
- the buffer into which the data is 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.- See Also:
FilterInputStream.read(byte[], int, int)
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.
This method simply performs in.read(b, off, len)
and returns the result.
- Overrides:
read
in class FilterInputStream
- 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.- See Also:
FilterInputStream.in