The java.io.InputStreamReader
class serves as a
bridge between byte streams and character streams: It reads
bytes from the input stream and translates them into characters
according to a specified character encoding.
The encoding can be set in the constructor, or you can accept the platform's default encoding.
public InputStreamReader(InputStream in)
public InputStreamReader(InputStream in, String encoding)
throws UnsupportedEncodingException
For example, if you wanted to read a file that had been encoded using the Macintosh Symbol font, you might do this:
FileInputStream fin = new FileInputStream("symbol.txt");
InputStreamReader reader = new InputStreamReader(fin, "MacSymbol");
The other methods just override methods from java.io.Reader
,
but behave identically from the perspective of the programmer:
public int read() throws IOException
public int read(char c[], int off, int length) throws IOException
public boolean ready() throws IOException
public void close() throws IOException