Class CloseShieldReader

  • All Implemented Interfaces:
    Closeable, AutoCloseable, Readable

    public class CloseShieldReader
    extends ProxyReader
    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
    • Constructor Detail

      • CloseShieldReader

        @Deprecated
        public CloseShieldReader​(Reader reader)
        Deprecated.
        Using this constructor prevents IDEs from warning if the underlying reader is never closed. Use wrap(Reader) instead.
        Creates a proxy that shields the given reader from being closed.
        Parameters:
        reader - underlying reader
    • Method Detail

      • wrap

        public static CloseShieldReader wrap​(Reader reader)
        Creates a proxy that shields the given reader from being closed.
        Parameters:
        reader - the reader to wrap
        Returns:
        the created proxy
        Since:
        2.9.0