Package org.apache.commons.io.input
Class CloseShieldInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- org.apache.commons.io.input.ProxyInputStream
-
- org.apache.commons.io.input.CloseShieldInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class CloseShieldInputStream extends ProxyInputStream
Proxy stream that prevents the underlying input stream from being closed.This class is typically used in cases where an input stream needs to be passed to a component that wants to explicitly close the stream even if more input would still be available to other components.
- Since:
- 1.4
-
-
Constructor Summary
Constructors Constructor Description CloseShieldInputStream(java.io.InputStream inputStream)
Deprecated.Using this constructor prevents IDEs from warning if the underlying input stream is never closed.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Replaces the underlying input stream with aClosedInputStream
sentinel.static CloseShieldInputStream
wrap(java.io.InputStream inputStream)
Creates a proxy that shields the given input stream from being closed.-
Methods inherited from class org.apache.commons.io.input.ProxyInputStream
available, mark, markSupported, read, read, read, reset, skip
-
-
-
-
Constructor Detail
-
CloseShieldInputStream
@Deprecated public CloseShieldInputStream(java.io.InputStream inputStream)
Deprecated.Using this constructor prevents IDEs from warning if the underlying input stream is never closed. Usewrap(InputStream)
instead.Creates a proxy that shields the given input stream from being closed.- Parameters:
inputStream
- underlying input stream
-
-
Method Detail
-
wrap
public static CloseShieldInputStream wrap(java.io.InputStream inputStream)
Creates a proxy that shields the given input stream from being closed.- Parameters:
inputStream
- the input stream to wrap- Returns:
- the created proxy
- Since:
- 2.9.0
-
close
public void close()
Replaces the underlying input stream with aClosedInputStream
sentinel. The original input stream will remain open, but this proxy will appear closed.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classProxyInputStream
-
-