Class EncodedInputStream
java.lang.Object
java.io.InputStream
org.apache.derby.client.net.EncodedInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
Create an encoded stream from a
Reader.
This is an internal class, used to pass readers of characters as streams of
bytes. The characters will be represented according to the specified
encoding. It is up to the caller to ensure the specified encoding is
available, and in general only encodings available as default from Java 1.3
and up should be used.
Currently, the encodings 'UTF8' and 'UTF-16BE' are used.
Streams are obtained by calling the static methods of this class,
for instance createUTF8Stream.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate final char[]private ByteArrayInputStreamprivate PublicBufferOutputStreamprivate OutputStreamWriterprivate Readerprivate static final ByteArrayInputStreamprivate static final Charsetprivate static final Charset -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateEncodedInputStream(Reader reader, Charset encoding, int charBufferSize, int initialByteBufferSize) Create an encoded stream for the specifiedReader. -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()(package private) static EncodedInputStreamcreateUTF16BEStream(Reader reader) Create a UTF-16BE encoded stream from the givenReader.static EncodedInputStreamcreateUTF8Stream(Reader reader) Create a UTF-8 encoded stream from the givenReader.intread()private ByteArrayInputStreamMethods inherited from class InputStream
mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Field Details
-
UTF_8
-
UTF_16BE
-
BUFFERED_CHAR_LEN
private static final int BUFFERED_CHAR_LEN- See Also:
-
suspendMarker
-
reader_
-
decodedBuffer_
private final char[] decodedBuffer_ -
encodedStreamWriter_
-
encodedOutputStream_
-
encodedInputStream_
-
-
Constructor Details
-
EncodedInputStream
private EncodedInputStream(Reader reader, Charset encoding, int charBufferSize, int initialByteBufferSize) Create an encoded stream for the specifiedReader.- Parameters:
reader- theReaderto read characters fromencoding- the encoding to use in the encoded streamcharBufferSize- the size of the char buffer. This is the number of characters read at once from theReader.initialByteBufferSize- the initial size of the byte buffer. holding the encoded bytes
-
-
Method Details
-
createUTF8Stream
Create a UTF-8 encoded stream from the givenReader.- Parameters:
reader- theReaderto read characters from.- Returns:
- a byte-stream with UTF-8 encoded characters
-
createUTF16BEStream
Create a UTF-16BE encoded stream from the givenReader.- Parameters:
reader- theReaderto read characters from.- Returns:
- a byte-stream with UTF-16BE encoded characters
-
reEncode
- Throws:
IOException
-
available
- Overrides:
availablein classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-