public class EncodedStreamReader extends Reader
EncodedStreamReader
's
directly. Rather, for efficiency purposes, an object of this class
should be wrapped by a BufferedReader
.
An application can install a named Codec using Io.addCodec() and this class is able to access that codec via the name supplied to addCodec(). The java.io.InputStreamReader however will not be able to access these codecs when run under a Java VM. Therefore if you must use a specific Codec then you should use this class instead.
InputStreamReader
,
BufferedReader
,
InputStream
Constructor and Description |
---|
EncodedStreamReader(InputStream in)
This method initializes a new instance of
EncodedStreamReader
to read from the specified stream using the default encoding. |
EncodedStreamReader(InputStream in,
String encoding_name)
This method initializes a new instance of
EncodedStreamReader
to read from the specified stream using a caller supplied character
encoding scheme. |
EncodedStreamReader(InputStream in,
TextCodec codec)
This method initializes a new instance of
EncodedStreamReader
to read from the specified stream using a caller supplied character
encoding scheme. |
Modifier and Type | Method and Description |
---|---|
void |
close()
This method closes this stream, as well as the underlying
InputStream . |
TextCodec |
getCodec()
This method returns the name of the encoding that is currently in use
by this object.
|
int |
read(char[] dest,
int offset,
int length)
This method reads up to
length characters from the stream into
the specified array starting at index offset into the
array. |
public EncodedStreamReader(InputStream in)
EncodedStreamReader
to read from the specified stream using the default encoding.in
- The InputStream
to read frompublic EncodedStreamReader(InputStream in, String encoding_name) throws UnsupportedEncodingException
EncodedStreamReader
to read from the specified stream using a caller supplied character
encoding scheme. Note that due to a deficiency in the Java language
design, there is no way to determine which encodings are supported.in
- The InputStream
to read fromencoding_name
- The name of the encoding scheme to useUnsupportedEncodingException
- If the encoding scheme
requested is not available.public EncodedStreamReader(InputStream in, TextCodec codec)
EncodedStreamReader
to read from the specified stream using a caller supplied character
encoding scheme. Note that due to a deficiency in the Java language
design, there is no way to determine which encodings are supported.in
- The InputStream
to read fromencoding_name
- The name of the encoding scheme to useUnsupportedEncodingException
- If the encoding scheme
requested is not available.public void close() throws IOException
InputStream
.close
in class Reader
IOException
- If an error occurspublic TextCodec getCodec()
null
.The
- current encoding namepublic int read(char[] dest, int offset, int length) throws IOException
length
characters from the stream into
the specified array starting at index offset
into the
array.read
in class Reader
buf
- The character array to recieve the data readoffset
- The offset into the array to start storing characterslength
- The requested number of characters to read.IOException
- If an error occurs