| java.lang.Object java.io.InputStream java.io.FilterInputStream net.matuschek.util.LimitedBandwidthStream
LimitedBandwidthStream | public class LimitedBandwidthStream extends FilterInputStream (Code) | | A FilterInputStream with a limited bandwith
This implements an filter for an existing input stream that allows
it to limit the read bandwidth. This can be useful for network
streams that should be limited to a specified bandwidth.
author: Daniel Matuschek version: $id$ |
Method Summary | |
public int | read() Reads the next byte.
Reads the next byte of data from this input stream. | public int | read(byte[] b) | public int | read(byte[] b, int off, int len) Reads a block of bytes from the stream. |
starttime | long starttime(Code) | | start time *
|
usedtime | long usedtime(Code) | | used time *
|
LimitedBandwidthStream | public LimitedBandwidthStream(InputStream in, int bandwidth) throws IOException(Code) | | initializes the LimitedBandWidth stream
|
read | public int read() throws IOException(Code) | | Reads the next byte.
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.
If the bandwidth consumption exceeds the defined limit, read will block
until the bandwidth is in the limit again.
the next byte from the stream or -1 if end-of-stream |
read | public int read(byte[] b, int off, int len) throws IOException(Code) | | Reads a block of bytes from the stream.
If the bandwith is not limited, it simply used the
read(byte[], int, int) method of the input stream, otherwise it
uses multiple read() request to enforce bandwith limitation (this
is easier to implement using byte reads).
the number of bytes read or -1 at end of stream |
|
|