How to move file to another directory in java

Previous
Next
In this post, we will see how to move file to another directory in java. We will use java.io.File ‘s rename(File dest) to do it.

In below example, we will move config_new.properties from /Users/Arpit/Desktop/Folder1 to /Users/Arpit/Desktop/Folder2 .

Java Program:

When I ran above program, I got following output:

Previous
Next

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.

Add Comment

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.
You can like our facebook page Java2blog