黑马程序员-JAVA高级视频_IO输入与输出-19天-3(通过缓冲区复制文本文件)
package itcast.java16; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; /* * 通过缓冲区复制一个.java文件 * */ public class CopeTextDemo1 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader br = null; BufferedWriter bw = null; br = new BufferedReader(new FileReader("F:\\MapDemo1.java")); bw = new BufferedWriter(new FileWriter("C:\\MapDemo1.java")); String line = null; while ((line = br.readLine()) != null) { bw.write(line); bw.newLine(); bw.flush(); } br.close(); bw.close(); } }