public class FileRead3 {
/**
* 文件-(I流+转换流+缓冲流)--->程序
* 转换流,解码,指定字符集(字节到字符的桥梁)
* 缓冲流提高性能
* @throws IOException
*/
public static void main(String[] args) throws IOException {
//1,建立文件与程序的联系
File f=new File("D:/a.txt");
//2,选择流
BufferedReader/*InputStream*/ is=new BufferedReader(
new InputStreamReader(//转换流
new FileInputStream(f),"gbk"/*"utf-8"*/)
);
//3,操作数据
//byte[] flush=new byte[31/*1024*/];
String str=null;
while(null!=(str=is.readLine())){
System.err.println("在这里进行数据处理"+str);
}
is.close();
}
}
/**
* 文件-(I流+转换流+缓冲流)--->程序
* 转换流,解码,指定字符集(字节到字符的桥梁)
* 缓冲流提高性能
* @throws IOException
*/
public static void main(String[] args) throws IOException {
//1,建立文件与程序的联系
File f=new File("D:/a.txt");
//2,选择流
BufferedReader/*InputStream*/ is=new BufferedReader(
new InputStreamReader(//转换流
new FileInputStream(f),"gbk"/*"utf-8"*/)
);
//3,操作数据
//byte[] flush=new byte[31/*1024*/];
String str=null;
while(null!=(str=is.readLine())){
System.err.println("在这里进行数据处理"+str);
}
is.close();
}
}