ReaderInputStream accepts a UTF-16 char stream (Reader) as input and converts it to a UTF-8 byte stream (InputStream) as output.
This is the inverse of java.io.InputStreamReader which converts a binary stream to a character stream.
| Modifier and Type | Field and Description |
|---|---|
| private final ByteBuffer | |
| private final CharBuffer | |
| private static final int | |
| private final CharsetEncoder | |
| private boolean | endOfInput
true when all of the characters have been read from the reader into inbuf. |
| private final byte[] | |
| private final Reader |
| Access | Constructor and Description |
|---|---|
| public | |
| pack-priv | ReaderInputStream(Reader reader, int charBufferSize)
Allow ReaderInputStreamTest to use small buffers to force UTF-16 surrogate pairs to cross buffer boundaries in interesting ways. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private void | |
| public void | close()
Overrides java. Implements java. Closes this input stream and releases any system resources associated with the stream. |
| public int | read()
Implements abstract java. Reads the next byte of data from the input stream. |
| public int | read(byte[]
the buffer into which the data is read. b, int the start offset in array off, int b
at which the data is written.the maximum number of bytes to read. len)Overrides java. Reads up to |
| bbuf | back to summary |
|---|---|
| private final ByteBuffer bbuf | |
| cbuf | back to summary |
|---|---|
| private final CharBuffer cbuf | |
| DEFAULT_CHAR_BUFFER_SIZE | back to summary |
|---|---|
| private static final int DEFAULT_CHAR_BUFFER_SIZE | |
| encoder | back to summary |
|---|---|
| private final CharsetEncoder encoder | |
| endOfInput | back to summary |
|---|---|
| private boolean endOfInput true when all of the characters have been read from the reader into inbuf. | |
| oneByte | back to summary |
|---|---|
| private final byte[] oneByte | |
| reader | back to summary |
|---|---|
| private final Reader reader | |
| ReaderInputStream | back to summary |
|---|---|
| public ReaderInputStream(Reader reader) | |
| ReaderInputStream | back to summary |
|---|---|
| pack-priv ReaderInputStream(Reader reader, int charBufferSize) Allow ReaderInputStreamTest to use small buffers to force UTF-16 surrogate pairs to cross buffer boundaries in interesting ways. Because this constructor is package-private, the unit test must be in the same package. | |
| advance | back to summary |
|---|---|
| private void advance() throws IOException | |
| checkEncodeResult | back to summary |
|---|---|
| private void checkEncodeResult(CoderResult result) throws CharacterCodingException | |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this input stream and releases any system resources associated with the stream.
| |
| read | back to summary |
|---|---|
| public int read() throws IOException Implements abstract java. Doc from java. Reads the next byte of data from the input stream. The value byte is
returned as an
| |
| read | back to summary |
|---|---|
| public int read(byte[] b, int off, int len) throws IOException Overrides java. Doc from java. Reads up to This method blocks until input data is available, end of file is detected, or an exception is thrown. If The first byte read is stored into element In every case, elements
| |