【复制文本:按行复制文件】

时间:2021-09-02 21:03:18
package test;

import java.io.*;

/**
 * @author shusheng
 * @description 按行复制文件
 * @Email shusheng@yiji.com
 * @date 2018/11/12 15:12
 */
public class CopyFileDemo5 {

    public static void main(String[] args) throws IOException {
        //封装数据源
        BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\shusheng\\Pictures\\111.txt"));
        //封装目的地
        BufferedWriter bw = new BufferedWriter(new FileWriter("C:\\Users\\shusheng\\Pictures\\222.txt"));
        String line = null;
        while((line=br.readLine())!=null){
            bw.write(line);
            bw.newLine();
            bw.flush();
        }
        br.close();
        bw.close();
    }

}