org.apache.commons.io.input

## Class ClosedReader

- java.lang.Object
- - java.io.Reader
  - - org.apache.commons.io.input.ClosedReader

- All Implemented Interfaces:
    Closeable, AutoCloseable, Readable

      public class ClosedReader
      extends Reader

  Always returns `IOUtils.EOF` to all attempts to read something from it.

  Typically uses of this class include testing for corner cases in methods that accept readers and acting as a sentinel value instead of a `null` reader.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static ClosedReader` | `INSTANCE` The singleton instance.

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

      `lock`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClosedReader()` Construct a new instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `int` | `read(char[] cbuf, int off, int len)` Returns -1 to indicate that the stream is closed.

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

      `mark, markSupported, read, read, read, ready, reset, skip`

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

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

- - ### Field Detail

    - #### INSTANCE

          public static final ClosedReader INSTANCE

      The singleton instance.

  - ### Constructor Detail

    - #### ClosedReader

          public ClosedReader()

      Construct a new instance.

  - ### Method Detail

    - #### close

          public void close()
                     throws IOException

      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in class `Reader`
      Throws:
        `IOException`

    - #### read

          public int read(char[] cbuf,
                          int off,
                          int len)

      Returns -1 to indicate that the stream is closed.
      Specified by:
        `read` in class `Reader`
      Parameters:
        `cbuf` - ignored
        `off` - ignored
        `len` - ignored
      Returns:
        always -1