java_io_字符缓冲流(装饰器)纯文件的拷贝,使用缓冲流新增方法逐行读取和写入换行符
public static void main(String[]args)
{
File head=new File("D:/d/b");
File last=new File("D:/d/vv");
try(BufferedReader breader=new BufferedReader(new FileReader(head));
BufferedWriter bwriter=new BufferedWriter(new FileWriter(last))) {
//用新方法逐行读取
String line=null;
while((line=breader.readLine())!=null)
{
bwriter.write(line);//逐行写出
bwriter.newLine(); //每行写入一个换行符
bwriter.flush();
}
}catch(FileNotFoundException e)
{
e.printStackTrace();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
本文标题:java_io_字符缓冲流(装饰器)纯文件的拷贝,使用缓冲流新增方法逐行读取和写入换行符
标题URL:http://cdiso.cn/article/gehiih.html