public abstract class LimitOutputStream extends FilterOutputStream
This class extends FilterOutputStream to provide a framework for implementing output streams with write limitations or size restrictions. It tracks completion state and calls a callback when the stream is finished, preventing multiple completion attempts.
Subclasses implement specific limiting behavior while inheriting callback functionality and completion state management. Useful for implementing streams that need to enforce size limits or provide notification when writing is complete.
| Modifier and Type | Class and Description |
|---|---|
static interface |
LimitOutputStream.DoneCallback
Callback interface for notification when a limited output stream completes
|
| Modifier and Type | Field and Description |
|---|---|
protected LimitOutputStream.DoneCallback |
_callback |
protected boolean |
_isDone |
out| Constructor and Description |
|---|
LimitOutputStream(OutputStream out,
LimitOutputStream.DoneCallback done) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
isDone() |
protected void |
setDone()
flush(), call the callback, and set _isDone
|
void |
write(byte[] buf,
int off,
int len)
Subclasses MUST override the following method
such that it calls done() when finished
and throws EOFException if called again
|
void |
write(int c) |
close, flush, writeprotected final LimitOutputStream.DoneCallback _callback
protected boolean _isDone
public LimitOutputStream(OutputStream out, LimitOutputStream.DoneCallback done)
done - non-nullprotected boolean isDone()
protected void setDone()
throws IOException
IOExceptionpublic void write(byte[] buf,
int off,
int len)
throws IOException
write in class FilterOutputStreamIOExceptionpublic void write(int c)
throws IOException
write in class FilterOutputStreamIOException