带缓冲区的流中的特殊方法:
1.readline()不包括换行
2.newline() 换行,是跨平台的方法
\r\n 只支持windows系统
package com.fenqing.demo;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class demo6_buffered {
public static void main(String[] args) throws IOException {
// readline();
// newline();
}
public static void newline() throws FileNotFoundException, IOException {
BufferedReader br=new BufferedReader(new FileReader("zzz.txt"));
BufferedWriter bw=new BufferedWriter(new FileWriter("zzzcopy.txt"));
String line;
while((line=br.readLine())!=null){
bw.write(line);
bw.newLine(); //写出回车换行符
// bw.write("\r\n");
}
br.close();
}
public static void readline() throws FileNotFoundException, IOException {
BufferedReader br=new BufferedReader(new FileReader("xxx.txt"));
String line;
while((line=br.readLine())!=null){
System.out.println(line);
}
br.close();
}
}