package 课后作业;
/*
利用 BufferedReader 和 BufferedWriter 完成文本文件的复制
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class test2 {
public static void main(String[] args) throws IOException {
File file = new File("H:\\temp\\text.txt");
FileReader fileReader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(fileReader);
FileWriter fileWriter=new FileWriter("H:\\temp2\\text.txt");
BufferedWriter bufferedWriter=new BufferedWriter(fileWriter);
String str ;
while (((str=bufferedReader.readLine())!=null)){
bufferedWriter.write(str);
}
bufferedWriter.flush();
bufferedReader.close();
bufferedWriter.close();
}
}
利用 BufferedReader 和 BufferedWriter 完成文本文件的复制
最新推荐文章于 2022-04-30 13:40:14 发布