其他分享
首页 > 其他分享> > BufferedCopy

BufferedCopy

作者:互联网

BufferedCopy

代码演示

package polarbearpackage;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

public class BufferedCopy {
    public static void main(String[] args) throws Exception{
        //创建源文件路径和复制文件路径
        String srcFilePath = "D:\\polarBear.txt";
        String destFilePath = "D:\\polarBearCopy.txt";
        BufferedReader bufferedReader = new BufferedReader(new FileReader(srcFilePath));
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(destFilePath));
        String line;
        while ((line=bufferedReader.readLine())!=null){
            bufferedWriter.write(line);
            bufferedWriter.newLine();
        }
        bufferedReader.close();
        bufferedWriter.close();

    }
}

标签:java,String,bufferedWriter,BufferedReader,io,import,BufferedCopy
来源: https://blog.csdn.net/weixin_43791695/article/details/118066088