Possible Duplicate:
Standard concise way to copy a file in Java?
I have a set of .png files in a folder at location C:\Desktop\input\Acsady\dZI_3.png
. Now I wish to make a copy of the image into a different location C:\Desktop\input\final\Acsady\5_dZI_3.png
.
How do I go about doing it? I am currently having the following code which is not giving me the expected result.
String newName = outdir + File.separator + "final" + File.separator + nfname;
File newfname = new File(outdir + File.separator + "final" + File.separator + nfname);
String source = outdir + File.separator + lkupfname;
String target = outdir + File.separator + "final" + File.separator + nfname;
System.out.println("Copying file: "+source +" to "+target);
boolean status = filename.renameTo(newfname);
System.out.println("status : "+status);
I get status as false everytime which means that renameTo function was not successfull.