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();
}
}
标签:java,文本文件,BufferedReader,BufferedWriter,io,new,import From: https://blog.51cto.com/u_11343833/6091160