import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
public class Deconde{
public static void main (String []args) throws Exception{
FileInputStream fis=new FileInputStream("./document.txt"); //文件字节流
InputStreamReader isr=new InputStreamReader(fis,"UTF-8"); //字节流和字符流的桥梁,可以指定指定字符格式
String str=null;
//直接读取字符,只要编码问题没问题
int c=0;
while((c=isr.read())!=-1)
System.out.print((char)c);
System.out.println("______________________________________________________");
//将InputStreamReader 封装到缓冲流中,需要字符编码正确
BufferedReader br=new BufferedReader(isr);
str=br.readLine();
while(str!=null)
{
System.out.println(str);
str=br.readLine();
}
System.out.println("______________________________________________________");
//使用默认编码的InputStreamReader ,当为ANSI的时候没问题,但是读取UTF-8的时候出错。
BufferedReader br2=new BufferedReader(new InputStreamReader(fis));
str=br2.readLine();
while(str!=null)
{
System.out.println(str);
str=br2.readLine();
}
}
}