org.apache.commons.io.input

## Class ClosedInputStream

- java.lang.Object
- - java.io.InputStream
  - - org.apache.commons.io.input.ClosedInputStream

- All Implemented Interfaces:
    Closeable, AutoCloseable

      public class ClosedInputStream
      extends InputStream

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

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

  Since:
    1.4

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static ClosedInputStream` | `CLOSED_INPUT_STREAM` Deprecated. Use `INSTANCE`.
    `static ClosedInputStream` | `INSTANCE` The singleton instance.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClosedInputStream()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `read()` Returns -1 to indicate that the stream is closed.

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

      `available, close, mark, markSupported, read, read, 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 ClosedInputStream INSTANCE

      The singleton instance.
      Since:
        2.12.0

    - #### CLOSED_INPUT_STREAM

          @Deprecated
          public static final ClosedInputStream CLOSED_INPUT_STREAM

      Deprecated. Use `INSTANCE`.
      The singleton instance.

  - ### Constructor Detail

    - #### ClosedInputStream

          public ClosedInputStream()

  - ### Method Detail

    - #### read

          public int read()

      Returns -1 to indicate that the stream is closed.
      Specified by:
        `read` in class `InputStream`
      Returns:
        always -1

Copyright © 2002–2023 The Apache Software Foundation. All rights reserved.