Package org.apache.commons.io.output
Class CloseShieldOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.apache.commons.io.output.ProxyOutputStream
org.apache.commons.io.output.CloseShieldOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
Proxy stream that prevents the underlying output stream from being closed.
This class is typically used in cases where an output stream needs to be passed to a component that wants to explicitly close the stream even if other components would still use the stream for output.
- Since:
- 1.4
-
Field Summary
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a proxy that shields the given output stream from being closed. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Replaces the underlying output stream with aClosedOutputStream
sentinel.Methods inherited from class org.apache.commons.io.output.ProxyOutputStream
afterWrite, beforeWrite, flush, handleIOException, write, write, write
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
CloseShieldOutputStream
Creates a proxy that shields the given output stream from being closed.- Parameters:
out
- underlying output stream
-
-
Method Details
-
close
public void close()Replaces the underlying output stream with aClosedOutputStream
sentinel. The original output stream will remain open, but this proxy will appear closed.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classProxyOutputStream
-