T
- Type of the Writer passed in the constructor.public class CloseShieldWriter<T extends Writer> extends FilterWriter
A CloseShieldWriter
wraps some other Writer
, which
it uses as its basic sink of data. The class CloseShieldWriter
delegates all requests to the contained writer, except the
close() method that is not to the underlying stream.
This class is typically used in cases where a Writer
needs to be
passed to a component that wants to explicitly close the stream but other
components still need to write data on it.
out
Constructor and Description |
---|
CloseShieldWriter(T source)
Construct a
CloseShieldWriter that forwards the calls to the
source Writer passed in the constructor. |
Modifier and Type | Method and Description |
---|---|
void |
close() |
int |
getCloseCount()
Returns the number of time that close was called.
|
T |
getWrappedWriter()
Returns the wrapped (original)
Writer passed in the
constructor. |
flush, write, write, write
public CloseShieldWriter(T source)
CloseShieldWriter
that forwards the calls to the
source Writer passed in the constructor.T
- a T object.source
- original Writerpublic 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 FilterWriter
IOException
public int getCloseCount()
public T getWrappedWriter()
Returns the wrapped (original) Writer
passed in the
constructor.
Writer
passed in the constructorCopyright © 2008–2016. All rights reserved.