public class ClosedInputStream extends InputStream
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.
| Modifier and Type | Field and Description |
|---|---|
static ClosedInputStream |
INSTANCE
The singleton instance.
|
| Constructor and Description |
|---|
ClosedInputStream()
Constructs a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) static InputStream |
ifNull(InputStream in)
Returns
INSTANCE if the given InputStream is null, otherwise returns the given input stream. |
int |
read()
Returns
-1 to indicate that the stream is closed. |
int |
read(byte[] b,
int off,
int len)
Returns
-1 to indicate that the stream is closed. |
available, close, mark, markSupported, read, reset, skippublic static final ClosedInputStream INSTANCE
static InputStream ifNull(InputStream in)
INSTANCE if the given InputStream is null, otherwise returns the given input stream.in - the InputStream to test.INSTANCE if the given InputStream is null, otherwise returns the given input stream.public int read()
-1 to indicate that the stream is closed.read in class InputStream-1.public int read(byte[] b,
int off,
int len)
throws IOException
-1 to indicate that the stream is closed.read in class InputStreamb - ignored.off - ignored.len - ignored.IOException