package myio;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.zip.Inflater;
/**
* 演示字符输入流 InputStreamReader,只能读取文本文件
* @author 86156
*
*/
public class Demo8 {
public static void main(String[] args) throws Exception {
//创建文件输入流
FileInputStream fis = new FileInputStream("f:\\ccc.txt");
//创建字符输入流并指定输入的字符编码
InputStreamReader isr = new InputStreamReader(fis,"UTF-8");
//单个读取字符
// int len = 0;
// while((len = isr.read())!=-1){
// System.out.print((char)len);
// }
//读取多个字符
char[] bs = new char[1024];
int len = 0;
while ((len = isr.read(bs))!=-1) {
System.out.println(new String(bs, 0, len));
}
isr.close();
System.out.println("执行完毕");
}
}