Package org.apache.commons.io.input
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
Modifier and TypeMethodDescription(package private) static InputStreamifNull(InputStream in) ReturnsINSTANCEif the given InputStream is null, otherwise returns the given input stream.intread()Returns -1 to indicate that the stream is closed.intread(byte[] b, int off, int len) Returns -1 to indicate that the stream is closed.Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, reset, skip
-
Field Details
-
INSTANCE
The singleton instance.- Since:
- 2.12.0
-
CLOSED_INPUT_STREAM
Deprecated.UseINSTANCE.The singleton instance.
-
-
Constructor Details
-
ClosedInputStream
public ClosedInputStream()
-
-
Method Details
-
ifNull
ReturnsINSTANCEif the given InputStream is null, otherwise returns the given input stream.- Parameters:
in- the InputStream to test.- Returns:
INSTANCEif the given InputStream is null, otherwise returns the given input stream.
-
read
public int read()Returns -1 to indicate that the stream is closed.- Specified by:
readin classInputStream- Returns:
- always -1
-
read
Returns -1 to indicate that the stream is closed.- Overrides:
readin classInputStream- Parameters:
b- ignored.off- ignored.len- ignored.- Returns:
- always -1
- Throws:
IOException
-
INSTANCE.