IO 之 InputStream 和 Reader
package java.io;
// Representing an input stream of bytes.
public abstract class InputStream implements Closeable
// Abstract class for reading character streams.
public abstract class Reader implements Readable, Closeable
桥
An InputStreamReader is a bridge from byte streams to character streams.
/*
* <p> For top efficiency, consider wrapping an InputStreamReader within a
* BufferedReader. For example:
*
* <pre>
* BufferedReader in
* = new BufferedReader(new InputStreamReader(System.in));
* </pre>
*/
举例:
ByteArrayInputStream bais = new ByteArrayInputStream(bytes); InputStreamReader isr = new InputStreamReader(bais,Charset.forName(file.getCharset())); BufferedReader br = new BufferedReader(isr);