/*

* 复制文件

*/

public class FileReader3 {

public static void main(String[] args) {

copy_2();


}



public static void copy_2(){

//创建目的地

FileWriter fw=null;

FileReader fr=null;

try {

fw = new FileWriter("G:\\mydo.txt");

//与已有文件关联

fr=new FileReader("F:\\MyEclipse.txt");

char[] buf=new char[1024];

int len=0;

while((len=fr.read(buf))!=-1){

fw.write(buf,0,len);

}

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}finally{

try {

if(fw!=null){

fw.close();

}

if(fr!=null){

fr.close();

}


} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}


}



}

}