zno2

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);

 

posted on 2016-08-05 18:45  zno2  阅读(164)  评论(0编辑  收藏  举报

导航