public final class ReaderInputStream extends InputStream
An InputStream that converts characters from a Reader into bytes using an
arbitrary Charset.
This is an alternative to copying the data to an OutputStream via a Writer,
which is necessarily blocking. By implementing an InputStream it allows consumers to
"pull" as much data as they can handle, which is more convenient when dealing with flow
controlled, async APIs.
| Constructor and Description |
|---|
ReaderInputStream(Reader reader,
Charset charset)
Creates a new input stream that will encode the characters from
reader into bytes using
the given character set encoder. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
available, mark, markSupported, read, reset, skippublic ReaderInputStream(Reader reader, Charset charset)
reader into bytes using
the given character set encoder.reader - input sourcecharset - character set used for encoding chars to bytesIllegalArgumentException - if bufferSize is non-positivepublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionpublic int read()
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
read in class InputStreamIOExceptionCopyright © 2018 Guangshan Technology, Inc.. All rights reserved.