T
- Type of the OutputStream passed in the constructor.public class CloseOnceOutputStream<T extends OutputStream> extends FilterOutputStream
A decorating OutputStream
that prevents multiple invocations of
the close() method on the underlying stream.
Multiple invocation of the close()
method will result in only
one invocation of the same method on the underlying stream. This is useful
with some non standard OutputStream
that don't allow
close()
to be called multiple times.
out
Constructor and Description |
---|
CloseOnceOutputStream(T source)
Construct a
CloseOnceOutputStream that forwards the calls to
the source OutputStream passed in the constructor. |
Modifier and Type | Method and Description |
---|---|
void |
close() |
int |
getCloseCount()
Returns the number of time that close was called.
|
T |
getWrappedOutputStream()
Returns the wrapped (original)
OutputStream passed in the
constructor. |
flush, write, write, write
public CloseOnceOutputStream(T source)
CloseOnceOutputStream
that forwards the calls to
the source OutputStream passed in the constructor.source
- original OutputStreampublic void close() throws IOException
Multiple invocation of this method will result in only one invocation of
the close()
on the underlying stream.
close
in interface Closeable
close
in interface AutoCloseable
close
in class FilterOutputStream
IOException
public int getCloseCount()
com.gc.iotools.stream.is.inspection.DiagnosticOutputStream
public T getWrappedOutputStream()
Returns the wrapped (original) OutputStream
passed in the
constructor.
OutputStream
passed in the constructorCopyright © 2008–2016. All rights reserved.