net.sf.zig_project.gpl.simulation
Class SlowOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
net.sf.zig_project.gpl.simulation.SlowOutputStream
- public class SlowOutputStream
- extends FilterOutputStream
The SlowOutputStream class slows down a given OutputStream. This prevents the
given OutputStream from returning as soon as it is completed. Hence, the
behavior of this stream is to operate as slowly (or possibly slower) than
the specified data rate.
This class is used within the Simulation package, and hence is designed
for configuring simulated test environments, not for precision timing.
- Version:
- September 24, 2004
- Author:
- Frank Ziglar
Field Summary |
protected double |
nSpB
Delay time, in nanoseconds per Byte |
Method Summary |
void |
write(byte[] buf,
int off,
int len)
Writes a block of data. |
void |
write(int b)
Writes a single byte of data. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
nSpB
protected final double nSpB
- Delay time, in nanoseconds per Byte
SlowOutputStream
public SlowOutputStream(OutputStream out,
double BpS)
- Creates a SlowOutput emulator.
- Parameters:
out
- the OutputStream to slow downBpS
- the data rate to emulate, in Bytes / second
write
public void write(int b)
throws IOException
- Writes a single byte of data. This method will
pause long enough to emulate a slower speed as
specified. Presently, this method does not account
for the time required for the current thread to
obtain a lock on the OutputStream. It is recommended
that this OutputStream be buffered, instead of
calling this method directly, in order to provide
more accurate timing.
- Throws:
IOException
write
public void write(byte[] buf,
int off,
int len)
throws IOException
- Writes a block of data. The OutputStream will pause
long enough to emulate a slower speed as specified.
- Throws:
IOException