【复制文本:字符缓冲流】

时间:2022-06-18 16:03:38
package test;

import java.io.*;

/**
 * @author shusheng
 * @description 字符缓冲流
 * @Email shusheng@yiji.com
 * @date 2018/11/12 15:12
 */
public class CopyFileDemo4 {

    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"));
        char[] chs = new char[1024];
        int len = 0;
        while((len=br.read(chs))!=-1){
            bw.write(chs,0,len);
            bw.flush();
        }
        br.close();
        bw.close();
    }

}