class LimitedOutputStream
extends OutputStream
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
LimitedOutputStream(OutputStream realOut,
int limit)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
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
|
private OutputStream realOut
private int total
private int limit
public LimitedOutputStream(OutputStream realOut, int limit)
realOut
- The output stream to receive the limited outputlimit
- How many characters to limit it to.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public void write(byte[] b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in class OutputStream
IOException
public void write(int b) throws IOException
write
in class OutputStream
IOException