FileCpoy --- 代码

 1 import java.io.* ;
 2 
 3 public class FileCopy {
 4     public static void main(String[] args) {
 5         String inputFile = "D:/java03/day23/Test.txt" ;
 6         String outputFile = "D:/LX/Test.txt" ;
 7         
 8         FileReader r = null;
 9         FileWriter w = null;
10         
11         try {
12             r = new FileReader(new File(inputFile));
13             w = new FileWriter(new File(outputFile));
14             int b = 0;
15             
16             while((b = r.read()) != -1) {
17                 w.write(b);
18             }
19             w.flush();
20             
21         }catch(FileNotFoundException ex) {
22             ex.printStackTrace();
23         }catch(IOException ex) {
24             ex.printStackTrace();
25         }finally {
26             try{
27                 r.close();
28                 w.close();
29             }catch(IOException ex) {
30                 ex.printStackTrace();
31             }
32         }
33         System.out.println("复制完成!");
34         
35     }
36 }
原文地址:https://www.cnblogs.com/xuewuzhijing95hao/p/7120386.html