Package org.apache.commons.io.output
Class CloseShieldWriter
java.lang.Object
java.io.Writer
java.io.FilterWriter
org.apache.commons.io.output.ProxyWriter
org.apache.commons.io.output.CloseShieldWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
Proxy stream that prevents the underlying writer from being closed.
This class is typically used in cases where a writer needs to be passed to a component that wants to explicitly close the writer even if other components would still use the writer for output.
- Since:
- 2.7
-
Field Summary
Fields inherited from class java.io.FilterWriter
out -
Constructor Summary
ConstructorsConstructorDescriptionCloseShieldWriter(Writer out) Creates a proxy that shields the given writer from being closed. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Replaces the underlying writer with aClosedWritersentinel.Methods inherited from class org.apache.commons.io.output.ProxyWriter
afterWrite, append, append, append, beforeWrite, flush, handleIOException, write, write, write, write, writeMethods inherited from class java.io.Writer
nullWriter
-
Constructor Details
-
CloseShieldWriter
Creates a proxy that shields the given writer from being closed.- Parameters:
out- underlying writer
-
-
Method Details
-
close
public void close()Replaces the underlying writer with aClosedWritersentinel. The original writer will remain open, but this proxy will appear closed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classProxyWriter
-