public class GuardedOutputStream extends MeasuredOutputStream
OutputStream.
This is especially useful in unit testing to ensure that certain blocks of data do not exceed their allotted size.
An IOException is thrown if you attempt to write more data than this stream was told to allow.
written| Constructor and Description |
|---|
GuardedOutputStream(OutputStream
Constructs a new
GuardedOutputStream.
|
| Modifier and Type | Method and Description |
|---|---|
long |
getLimit()
The number of bytes that can still be written to this stream.
|
void |
write(byte[] b)
|
void |
write(byte[] b, int off, int len)
|
void |
write(int b)
|
addChangeListener, close, fireListeners, flush, getBytesWritten, isClosed, removeChangeListenerpublic GuardedOutputStream(OutputStreamout, long limit)
GuardedOutputStream.
out - the underlying
OutputStream to send data to.
limit - the number of bytes that can be written
public long getLimit()
(This value changes every time write() is called.)
public void write(byte[] b,
int off,
int len)
throws IOException
write in class
MeasuredOutputStream
IOException
public void write(byte[] b)
throws IOException
write in class
MeasuredOutputStream
IOException
public void write(int b)
throws IOException
write in class
MeasuredOutputStream
IOException