Class ReaderInputStream
java.lang.Object
java.io.InputStream
org.postgresql.util.ReaderInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ByteBufferprivate final CharBufferprivate static final intprivate final CharsetEncoderprivate booleantrue when all of the characters have been read from the reader into inbuf.private final byte[]private final Reader -
Constructor Summary
ConstructorsConstructorDescriptionReaderInputStream(Reader reader) ReaderInputStream(Reader reader, int charBufferSize) Allow ReaderInputStreamTest to use small buffers to force UTF-16 surrogate pairs to cross buffer boundaries in interesting ways. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidadvance()private static voidcheckEncodeResult(CoderResult result) voidclose()intread()intread(byte[] b, int off, int len) Methods inherited from class InputStream
available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Field Details
-
DEFAULT_CHAR_BUFFER_SIZE
private static final int DEFAULT_CHAR_BUFFER_SIZE- See Also:
-
reader
-
encoder
-
bbuf
-
cbuf
-
endOfInput
private boolean endOfInputtrue when all of the characters have been read from the reader into inbuf. -
oneByte
private final byte[] oneByte
-
-
Constructor Details
-
ReaderInputStream
-
ReaderInputStream
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.
-
-
Method Details
-
advance
- Throws:
IOException
-
checkEncodeResult
- Throws:
CharacterCodingException
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-