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 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.

- - ### Field Summary

    - ### Fields inherited from class java.io.FilterReader

      `in`

    - ### Fields inherited from class java.io.Reader

      `lock`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Replaces the underlying reader with a `ClosedReader` sentinel.
    `static CloseShieldReader` | `wrap(Reader reader)` Constructs a proxy that shields the given reader from being closed.

    - ### Methods inherited from class org.apache.commons.io.input.ProxyReader

      `afterRead, beforeRead, handleIOException, mark, markSupported, read, read, read, read, ready, reset, skip`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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 `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Overrides:
        `close` in class `ProxyReader`

    - #### wrap

          public static CloseShieldReader wrap(Reader reader)

      Constructs a proxy that shields the given reader from being closed.
      Parameters:
        `reader` - the reader to wrap
      Returns:
        the created proxy