com.ch.odi.io
Class BandwidthLimitInputStream
java.lang.Object
|
+--java.io.InputStream
|
+--com.ch.odi.io.BandwidthLimitInputStream
- public class BandwidthLimitInputStream
- extends InputStream
Description: This is an input stream that limits throughput.
Copyright: Copyright (c) 2001
|
Method Summary |
int |
available()
|
void |
close()
|
void |
mark(int readlimit)
|
boolean |
markSupported()
|
int |
read()
|
int |
read(byte[] b)
|
int |
read(byte[] b,
int off,
int len)
|
void |
reset()
|
void |
setLimit(int bytes,
long time)
Sets the bandwidth limit
Sample: bytes=300, time=500 means you can not read more than 300 bytes within 500 milliseconds |
long |
skip(long n)
|
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
BandwidthLimitInputStream
public BandwidthLimitInputStream(InputStream in)
- Creates a Stream
The default limit is 9600 bytes per second
- Parameters:
in - The underlying input stream
setLimit
public void setLimit(int bytes,
long time)
- Sets the bandwidth limit
Sample: bytes=300, time=500 means you can not read more than 300 bytes within 500 milliseconds
markSupported
public boolean markSupported()
- Overrides:
- markSupported in class InputStream
mark
public void mark(int readlimit)
- Overrides:
- mark in class InputStream
reset
public void reset()
throws IOException
- Overrides:
- reset in class InputStream
read
public int read()
throws IOException
- Overrides:
- read in class InputStream
read
public int read(byte[] b)
throws IOException
- Overrides:
- read in class InputStream
read
public int read(byte[] b,
int off,
int len)
throws IOException
- Overrides:
- read in class InputStream
available
public int available()
- Overrides:
- available in class InputStream
skip
public long skip(long n)
throws IOException
- Overrides:
- skip in class InputStream
close
public void close()
throws IOException
- Overrides:
- close in class InputStream