org.cdlib.xtf.util
Class LimitedOutputStream

Object
  extended by OutputStream
      extended by LimitedOutputStream
All Implemented Interfaces:
Closeable, Flushable

 class LimitedOutputStream
extends OutputStream

This class is useful only for testing the transmission speed of data by limiting the size of the output stream. Not to be used in production.


Field Summary
private  int limit
          The limit on the number of bytes
private  OutputStream realOut
          The output stream to receive the limited output
private  int total
          How many bytes have been output so far
 
Constructor Summary
LimitedOutputStream(OutputStream realOut, int limit)
          Constructor.
 
Method Summary
 void close()
          Close the output stream
 void flush()
          Flush any pending data to the output stream
 void write(byte[] b)
          Write an array of bytes to the output stream
 void write(byte[] b, int off, int len)
          Write a subset of bytes to the stream
 void write(int b)
          Write a single byte to the stream
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

realOut

private OutputStream realOut
The output stream to receive the limited output


total

private int total
How many bytes have been output so far


limit

private int limit
The limit on the number of bytes

Constructor Detail

LimitedOutputStream

public LimitedOutputStream(OutputStream realOut,
                           int limit)
Constructor.

Parameters:
realOut - The output stream to receive the limited output
limit - How many characters to limit it to.
Method Detail

close

public void close()
           throws IOException
Close the output stream

Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException

flush

public void flush()
           throws IOException
Flush any pending data to the output stream

Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException

write

public void write(byte[] b)
           throws IOException
Write an array of bytes to the output stream

Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Write a subset of bytes to the stream

Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(int b)
           throws IOException
Write a single byte to the stream

Specified by:
write in class OutputStream
Throws:
IOException