@Beta public final class ReaderInputStream extends InputStream
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,
CharsetEncoder encoder,
int bufferSize)
Creates a new input stream that will encode the characters from
reader into bytes using
the given character set encoder. |
ReaderInputStream(Reader reader,
Charset charset,
int bufferSize)
Creates a new input stream that will encode the characters from
reader into bytes using
the given character set. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
String |
toString() |
available, mark, markSupported, read, reset, skippublic ReaderInputStream(Reader reader, Charset charset, int bufferSize)
reader into bytes using
the given character set. Malformed input and unmappable characters will be replaced.reader - input sourcecharset - character set used for encoding chars to bytesbufferSize - size of internal input and output buffersIllegalArgumentException - if bufferSize is non-positivepublic ReaderInputStream(Reader reader, CharsetEncoder encoder, int bufferSize)
reader into bytes using
the given character set encoder.reader - input sourceencoder - character set encoder used for encoding chars to bytesbufferSize - size of internal input and output buffersIllegalArgumentException - 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 SPF4J. All rights reserved.