package file_Stream;import java.io.File;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;public class TextCopyText { public static void main(String[] args) { File file1 = new File("D:\\source.txt"); File file2 = new File("D:\\dest.txt"); FileReader fr = null; FileWriter fw = null; int c = 0; try{ if(!file1.exists()){ file1.createNewFile(); } if(!file2.exists()){ file2.createNewFile(); } fr = new FileReader(file1); fw = new FileWriter(file2); fw.flush(); fw.write(file1.getName()); fw.write("\n\n"); while((c = fr.read()) != -1){ fw.write(c); } fw.flush(); }catch(FileNotFoundException e){ e.printStackTrace(); }catch(IOException e){ e.printStackTrace(); }finally{ try{ if(null != fw){ fw.close(); } }catch(IOException e){ e.printStackTrace(); } try{ if(null != fr){ fw.close(); } }catch(IOException e){ e.printStackTrace(); } } }}写的有点乱。