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 writer 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 SummaryFields inherited from class java.io.FilterWriterout
- 
Constructor SummaryConstructorsConstructorDescriptionCloseShieldWriter(Writer writer) Deprecated.Using this constructor prevents IDEs from warning if the underlying writer is never closed.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Replaces the underlying writer with aClosedWritersentinel.static CloseShieldWriterConstructs a proxy that shields the given writer from being closed.Methods inherited from class org.apache.commons.io.output.ProxyWriterafterWrite, append, append, append, beforeWrite, flush, handleIOException, write, write, write, write, write
- 
Constructor Details- 
CloseShieldWriterDeprecated.Using this constructor prevents IDEs from warning if the underlying writer is never closed. Usewrap(Writer)instead.Constructs a proxy that shields the given writer from being closed.- Parameters:
- writer- underlying writer
 
 
- 
- 
Method Details- 
wrapConstructs a proxy that shields the given writer from being closed.- Parameters:
- writer- the writer to wrap
- Returns:
- the created proxy
- Since:
- 2.9.0
 
- 
closeReplaces the underlying writer with aClosedWritersentinel. The original writer will remain open, but this proxy will appear closed.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Overrides:
- closein class- ProxyWriter
 
 
-