|
Final | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.io.Reader
java.io.InputStreamReader
public class InputStreamReader
InputStreamReader is class for turning a byte Stream into a character Stream. Data read from the source input stream is converted into characters by either a default or provided character converter. By default, the encoding is assumed to ISO8859_1. The InputStreamReader contains a buffer of bytes read from the source input stream and converts these into characters as needed. The buffer size is 8K.
OutputStreamWriter| Field Summary |
|---|
| Fields inherited from class java.io.Reader |
|---|
lock |
| Constructor Summary | |
|---|---|
InputStreamReader(InputStream in)
Constructs a new InputStreamReader on the InputStream in. |
|
InputStreamReader(InputStream in,
Charset charset)
Constructs a new InputStreamReader on the InputStream in. |
|
InputStreamReader(InputStream in,
CharsetDecoder decoder)
Constructs a new InputStreamReader on the InputStream in. |
|
InputStreamReader(InputStream in,
String enc)
Constructs a new InputStreamReader on the InputStream in. |
|
| Method Summary | |
|---|---|
void |
close()
Close this InputStreamReader. |
String |
getEncoding()
Answer the String which identifies the encoding used to convert bytes to characters. |
int |
read()
Reads a single character from this InputStreamReader and returns the result as an int. |
int |
read(char[] buf,
int offset,
int length)
Reads at most count characters from this Reader and stores them
at offset in the character array buf. |
boolean |
ready()
Answers a boolean indicating whether or not this
InputStreamReader is ready to be read without blocking. |
| Methods inherited from class java.io.Reader |
|---|
mark, markSupported, read, read, reset, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public InputStreamReader(InputStream in)
in. Now
character reading can be filtered through this InputStreamReader. This constructor
uses the Charset.defaultCharset().
in - the InputStream to convert to characters.public InputStreamReader(InputStream in,
String enc)
throws UnsupportedEncodingException
in. Now
character reading can be filtered through this InputStreamReader. This constructor
takes a String parameter enc which is the name of an encoding.
If the encoding cannot be found, an UnsupportedEncodingException error is thrown.
in - the InputStream to convert to characters.enc - a String describing the character converter to use.
UnsupportedEncodingException - if the encoding cannot be found.public InputStreamReader(InputStream in,
Charset charset)
in. Now
character reading can be filtered through this InputStreamReader using
the given character set.
in - the InputStream to convert to characters.charset - the character set to use.public InputStreamReader(InputStream in,
CharsetDecoder decoder)
in. Now
character reading can be filtered through this InputStreamReader using
the given character set decoder.
in - the InputStream to convert to characters.decoder - the character set ecoder to use.| Method Detail |
|---|
public void close()
throws IOException
close in interface Closeableclose in class ReaderIOException - If an error occurs attempting to close this InputStreamReader.public String getEncoding()
null is returned if this Reader has been closed.
public int read()
throws IOException
read in class ReaderIOException - If the InputStreamReader is already closed or some other IO error occurs.public int read(char[] buf,
int offset,
int length)
throws IOException
count characters from this Reader and stores them
at offset in the character array buf. Returns the
number of characters actually read or -1 if the end of reader was encountered.
The bytes are either obtained from converting bytes in this readers buffer or
by first filling the buffer from the source InputStream and then reading from the
buffer.
read in class Readerbuf - character array to store the read charactersoffset - offset in buf to store the read characterslength - maximum number of characters to read
IOException - If the InputStreamReader is already closed or some other IO error occurs.public boolean ready()
throws IOException
boolean indicating whether or not this
InputStreamReader is ready to be read without blocking. If the result
is true, the next read() will not
block. If the result is false this Reader may
or may not block when read() is sent. This implementation
answers true if there are bytes available in the buffer or
the source InputStream has bytes available.
ready in class Readertrue if the receiver will not block when read() is
called, false if unknown or blocking will occur.
IOException - If the InputStreamReader is already closed or some other IO error occurs.
|
Final | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||