Class: java.io.InputStreamReader
- public class InputStreamReader
- extends Reader
charset. The charset that it uses
may be specified by name or may be given explicitly, or the platform's
default charset may be accepted.
Each invocation of one of an InputStreamReader's read() methods may cause one or more bytes to be read from the underlying byte-input stream. To enable the efficient conversion of bytes to characters, more bytes may be read ahead from the underlying stream than are necessary to satisfy the current read operation.
For top efficiency, consider wrapping an InputStreamReader within a BufferedReader. For example:
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
Methods
-
InputStreamReadertop
public InputStreamReader(InputStream in)Create an InputStreamReader that uses the default charset. -
InputStreamReadertop
Create an InputStreamReader that uses the named charset. -
InputStreamReadertop
public InputStreamReader(InputStream in, Charset cs)Create an InputStreamReader that uses the given charset. -
InputStreamReadertop
public InputStreamReader(InputStream in, CharsetDecoder dec)Create an InputStreamReader that uses the given charset decoder. -
closetop
public void close() throws IOExceptionClose the stream. -
getEncodingtop
public String getEncoding()Return the name of the character encoding being used by this stream.If the encoding has an historical name then that name is returned; otherwise the encoding's canonical name is returned.
If this instance was created with the java.io.InputStreamReader.InputStreamReader(java.io.InputStream, java.lang.String) constructor then the returned name, being unique for the encoding, may differ from the name passed to the constructor. This method may return
nullif the stream has been closed. -
readtop
public int read() throws IOExceptionRead a single character. -
readtop
public int read(char[] cbuf, int offset, int length) throws IOExceptionRead characters into a portion of an array. -
readytop
public boolean ready() throws IOExceptionTell whether this stream is ready to be read. An InputStreamReader is ready if its input buffer is not empty, or if bytes are available to be read from the underlying byte stream.
