Package org.apache.derby.client.net
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 int
private final char[]
private ByteArrayInputStream
private PublicBufferOutputStream
private OutputStreamWriter
private Reader
private static final ByteArrayInputStream
private static final Charset
private static final Charset
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
EncodedInputStream
(Reader reader, Charset encoding, int charBufferSize, int initialByteBufferSize) Create an encoded stream for the specifiedReader
. -
Method Summary
Modifier and TypeMethodDescriptionint
void
close()
(package private) static EncodedInputStream
createUTF16BEStream
(Reader reader) Create a UTF-16BE encoded stream from the givenReader
.static EncodedInputStream
createUTF8Stream
(Reader reader) Create a UTF-8 encoded stream from the givenReader
.int
read()
private ByteArrayInputStream
Methods inherited from class java.io.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
- theReader
to 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
- theReader
to read characters from.- Returns:
- a byte-stream with UTF-8 encoded characters
-
createUTF16BEStream
Create a UTF-16BE encoded stream from the givenReader
.- Parameters:
reader
- theReader
to read characters from.- Returns:
- a byte-stream with UTF-16BE encoded characters
-
reEncode
- Throws:
IOException
-
available
- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-