Reputation: 17
I copy a file from a directory for another but I have a difficulty to find the new file path ! I used FileUtils class from apache commons-io library to do that..... please is that there a function can save the last file path ?
Upvotes: 1
Views: 147
Reputation: 62835
Since FileUtils.moveFile accepts two arguments -- source file and destination file, all you need to do is to use second arg:
File myFile = new File("file");
File newLocation = new File("funky_file");
FileUtils.copyFile(myFile, newLocation);
myFile = newLocation;
You cannot retrive new location basing only on myFile without reassigning: File class is designed to be a immutable path rather that hard link to the file.
Upvotes: 1