Class ClosedInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.io.input.ClosedInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
Always returns
IOUtils.EOF to all attempts to read something from an input 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
FieldsModifier and TypeFieldDescriptionstatic final ClosedInputStreamDeprecated.static final ClosedInputStreamThe singleton instance. -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class InputStream
available, close, mark, markSupported, read, reset, skip
-
Field Details
-
INSTANCE
-
CLOSED_INPUT_STREAM
Deprecated.UseINSTANCE.The singleton instance.
-
-
Constructor Details
-
ClosedInputStream
public ClosedInputStream()Constructs a new instance.
-
-
Method Details
-
read
Returns-1to indicate that the stream is closed.- Specified by:
readin classInputStream- Returns:
- always
-1.
-
read
Returns-1to indicate that the stream is closed.- Overrides:
readin classInputStream- Parameters:
b- The buffer to read bytes into.off- The start offset.len- The number of bytes to read.- Returns:
- If len is zero, then
0; otherwise-1. - Throws:
NullPointerException- if the byte array isnull.IndexOutOfBoundsException- ifofforlenare negative, or ifoff + lenis greater thanb.length.IOException
-
INSTANCE.