用打印流来进行文件读写复制
//需求: DataStreamDemo . j ava复制到Copy. java中
// 数据源:
// DataStreamDemo. java --读职数据 – FileReader – BufferedReader
// 目的地:
// Copy.java --写出数据一一FileWriter – BufferedWriter – Printwriter
package cn.study_03;
import java.io.*;
//需求: DataStreamDemo . j ava复制到Copy. java中
// 数据源:
// DataStreamDemo. java --读职数据 -- FileReader -- BufferedReader
// 目的地:
// Copy.java --写出数据一一FileWriter -- BufferedWriter -- Printwriter
public class PrintWriteDemo2 {
public static void main(String[] args) throws IOException {
BufferedReader br =new BufferedReader(new FileReader("pw2.txt"));
PrintWriter pw =new PrintWriter(new FileWriter("copy.txt"),true);
String line =null;
while ((line=br.readLine())!=null){
pw.println(line);
}
br.close();
pw.close();
}
}