Package org.apache.commons.io.input
Class CloseShieldReader
- java.lang.Object
-
- java.io.Reader
-
- java.io.FilterReader
-
- org.apache.commons.io.input.ProxyReader
-
- org.apache.commons.io.input.CloseShieldReader
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
public class CloseShieldReader extends ProxyReader
Proxy stream that prevents the underlying reader from being closed.This class is typically used in cases where a reader needs to be passed to a component that wants to explicitly close the reader even if more input would still be available to other components.
- Since:
- 2.7
-
-
Constructor Summary
Constructors Constructor Description CloseShieldReader(Reader in)
Creates a proxy that shields the given reader from being closed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Replaces the underlying reader with aClosedReader
sentinel.-
Methods inherited from class org.apache.commons.io.input.ProxyReader
mark, markSupported, read, read, read, read, ready, reset, skip
-
Methods inherited from class java.io.Reader
nullReader, transferTo
-
-
-
-
Constructor Detail
-
CloseShieldReader
public CloseShieldReader(Reader in)
Creates a proxy that shields the given reader from being closed.- Parameters:
in
- underlying reader
-
-
Method Detail
-
close
public void close()
Replaces the underlying reader with aClosedReader
sentinel. The original reader will remain open, but this proxy will appear closed.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classProxyReader
-
-