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
Proxy reader 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
- 
Field SummaryFields inherited from class java.io.FilterReaderin
- 
Constructor SummaryConstructorsConstructorDescriptionCloseShieldReader(Reader reader) Deprecated.Using this constructor prevents IDEs from warning if the underlying reader is never closed.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Replaces the underlying reader with aClosedReadersentinel.static CloseShieldReaderConstructs a proxy that shields the given reader from being closed.Methods inherited from class org.apache.commons.io.input.ProxyReaderafterRead, beforeRead, handleIOException, mark, markSupported, read, read, read, read, ready, reset, skip
- 
Constructor Details- 
CloseShieldReaderDeprecated.Using this constructor prevents IDEs from warning if the underlying reader is never closed. Usewrap(Reader)instead.Constructs a proxy that shields the given reader from being closed.- Parameters:
- reader- underlying reader
 
 
- 
- 
Method Details- 
wrapConstructs a proxy that shields the given reader from being closed.- Parameters:
- reader- the reader to wrap
- Returns:
- the created proxy
- Since:
- 2.9.0
 
- 
closeReplaces the underlying reader with aClosedReadersentinel. The original reader will remain open, but this proxy will appear closed.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Overrides:
- closein class- ProxyReader
 
 
-