Class InputStreamReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
InputStream
s serialized inside an underlying InputStream
by an OutputStreamWriter
.
Instances of this class are thread safe, as are the InputStream
s returned by read()
.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close this instance.read()
Read the nextInputStream
.
-
Constructor Details
-
InputStreamReader
Constructor.- Parameters:
input
- the underlyingInputStream
that will carry nestedInputStream
s within it
-
-
Method Details
-
read
Read the nextInputStream
.The returned
InputStream
will remain valid as long as it has not been closed, the underlying input has not been closed, and no subsequent invocation of this method has been made. As soon as any of those events occurs, all subsequent accesses to the previously returnedInputStream
will throw an exception.The returned
InputStream
may be closed prior to its EOF, in which case any remaining bytes will be skipped over during the next invocation of this method.Note: while any thread is blocked reading from the returned
InputStream
, this method will block as well.- Returns:
- the next
InputStream
, ornull
if EOF has been reached on the underlying input - Throws:
IOException
- if this instance is closedIOException
- if the underlyingInputStream
has thrown an exception
-
close
Close this instance. Does nothing if already closed.This closes the underlying input; however, if the
InputStream
most recently returned fromread()
is still open, the close of the underlying input will be postponed until it is no longer open.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- if an there is an error closing the underlyingInputStream
-