Package net.i2p.i2ptunnel.util
Class LimitOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- net.i2p.i2ptunnel.util.LimitOutputStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
- Direct Known Subclasses:
ByteLimitOutputStream
,DechunkedOutputStream
public abstract class LimitOutputStream extends FilterOutputStream
Base class for limiting writes and calling a callback when finished- Since:
- 0.9.62
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
LimitOutputStream.DoneCallback
-
Field Summary
Fields Modifier and Type Field Description protected LimitOutputStream.DoneCallback
_callback
protected boolean
_isDone
-
Fields inherited from class java.io.FilterOutputStream
out
-
-
Constructor Summary
Constructors Constructor Description LimitOutputStream(OutputStream out, LimitOutputStream.DoneCallback done)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
isDone()
protected void
setDone()
flush(), call the callback, and set _isDonevoid
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 againvoid
write(int c)
-
Methods inherited from class java.io.FilterOutputStream
close, flush, write
-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Field Detail
-
_callback
protected final LimitOutputStream.DoneCallback _callback
-
_isDone
protected boolean _isDone
-
-
Constructor Detail
-
LimitOutputStream
public LimitOutputStream(OutputStream out, LimitOutputStream.DoneCallback done)
- Parameters:
done
- non-null
-
-
Method Detail
-
write
public void write(int c) throws IOException
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
public void write(byte[] buf, int off, int len) throws IOException
Subclasses MUST override the following method such that it calls done() when finished and throws EOFException if called again- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
isDone
protected boolean isDone()
-
setDone
protected void setDone() throws IOException
flush(), call the callback, and set _isDone- Throws:
IOException
-
-