How to move file to another directory in java

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:

Add Comment