Class CloseShieldReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.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
    • Field Summary

      • Fields inherited from class java.io.FilterReader

        in
      • Fields inherited from class java.io.Reader

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      CloseShieldReader​(java.io.Reader in)
      Creates a proxy that shields the given reader from being closed.
    • Constructor Detail

      • CloseShieldReader

        public CloseShieldReader​(java.io.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 a ClosedReader sentinel. The original reader will remain open, but this proxy will appear closed.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class ProxyReader