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_字符緩沖流(裝飾器)純文件的拷貝,使用緩沖流新增方法逐行讀取和寫入換行符
文章分享:
http://weahome.cn/article/gehiih.html