public class Demo4_Buffered(){
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader (new FileRead("xxx.txt"));
String line;
while((line = br.readLine()) != null){ //整行读取
syso(line);
}
br.close();
}
}
public class Demo5_Buffered(){
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader (new FileRead("xxx.txt"));
BufferedWriter bw = new BufferedWriter (new FileWriter("aaa.txt"));
String line;
while((line = br.readLine()) != null){ //整行读取
bw.writer(line);
bw.newLine(); //写出回车换行符 和bw.write("\r\n");一个效果,但是newLine()是支持各种操作平台的
}
br.close();
bw.close();
}
}
IO流,带缓冲区的流中的特殊方法:readLine()和newLine()方法。
原文:https://www.cnblogs.com/wangffeng293/p/13179402.html