package Zjshuchu; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class BufferedCopy { //缓冲字符流的复制 public static void main(String[] args) throws IOException { //获取数据源 FileReader fr=new FileReader("d:\java\writer.txt"); //封装成缓冲流 BufferedReader br=new BufferedReader(fr); //3、确定目的地 FileWriter fw=new FileWriter("e:\java\copy.txt"); //4、封装成缓冲流 BufferedWriter bw=new BufferedWriter(fw); //复制 String str=null; while((str=br.readLine())!=null){ bw.write(str); bw.newLine(); bw.flush(); } //6、释放资源 br.close(); bw.close(); } }