package com.sf._05_缓冲流;

import java.io.*;

public class Test1 {
    /**
     * 把D: a.txt 文件内容按行读取
     * 写的时候按照行去写
     *
     * 要求使用字符缓冲流
     */
    public static void main(String[] args) throws IOException {
        // 创建字符流
        FileReader fileReader = new FileReader(new File("D:\\a.txt"));
        FileWriter fileWriter = new FileWriter(new File("D:\\f.txt"));
        //创建包装流
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);

        String str;
        while ((str = bufferedReader.readLine())!=null){
            bufferedWriter.write(str);
            bufferedWriter.newLine();
        }
        // 关闭资源
        bufferedReader.close();
        bufferedWriter.close();
    }
}
