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 Details

  • Constructor Details

    • ClosedInputStream

      public ClosedInputStream()
  • Method Details

    • read

      public int read()
      Returns -1 to indicate that the stream is closed.
      Specified by:
      read in class InputStream
      Returns:
      always -1
    • read

      public int read(byte[] b, int off, int len) throws IOException
      Returns -1 to indicate that the stream is closed.
      Overrides:
      read in class InputStream
      Parameters:
      b - ignored.
      off - ignored.
      len - ignored.
      Returns:
      always -1
      Throws:
      IOException