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
public class CloseShieldWriter extends ProxyWriter
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
-
-
Constructor Summary
Constructors Constructor Description CloseShieldWriter(Writer out)
Creates a proxy that shields the given writer from being closed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Replaces the underlying writer with aClosedWriter
sentinel.-
Methods inherited from class org.apache.commons.io.output.ProxyWriter
append, append, append, flush, write, write, write, write, write
-
Methods inherited from class java.io.Writer
nullWriter
-
-
-
-
Constructor Detail
-
CloseShieldWriter
public CloseShieldWriter(Writer out)
Creates a proxy that shields the given writer from being closed.- Parameters:
out
- underlying writer
-
-
Method Detail
-
close
public void close()
Replaces the underlying writer with aClosedWriter
sentinel. The original writer will remain open, but this proxy will appear closed.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classProxyWriter
-
-