Class InputStreamReader
- All Implemented Interfaces:
Closeable,AutoCloseable
InputStreams serialized inside an underlying InputStream by an OutputStreamWriter.
Instances of this class are thread safe, as are the InputStreams returned by read().
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close this instance.read()Read the nextInputStream.
-
Constructor Details
-
InputStreamReader
Constructor.- Parameters:
input- the underlyingInputStreamthat will carry nestedInputStreams within it
-
-
Method Details
-
read
Read the nextInputStream.The returned
InputStreamwill 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 returnedInputStreamwill throw an exception.The returned
InputStreammay 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, ornullif EOF has been reached on the underlying input - Throws:
IOException- if this instance is closedIOException- if the underlyingInputStreamhas thrown an exception
-
close
Close this instance. Does nothing if already closed.This closes the underlying input; however, if the
InputStreammost recently returned fromread()is still open, the close of the underlying input will be postponed until it is no longer open.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if an there is an error closing the underlyingInputStream
-