Moving a file from one location to another using Java

by guruprasad 2014-01-02 09:47:15

Moving a file from one location to another:

Used function:

renameTo();



Example:


File afile =new File("C:\folderA\Afile.txt"); //getting file name with its
location.
if(afile.renameTo(new File("C:\folderB\" + afile.getName()))){
System.out.println("File is moved successful!");
}else{
System.out.println("File is failed to move!");
}

925
like
0
dislike
0
mail
flag

You must LOGIN to add comments