How to move a folder (including subdirectories and files) to a new folder using Java code

Can someone help me for Java code that copies or moves one folder as it is in another folder.

For instance:
I have a folder called temp , inside temp I have an in-temp folder.

I want my temp folder to be copied or moved to a new folder named new temp , but using Java code.

I got a sample code by doing a search on Google that copies the subdirectories and files of the folder to a new folder, but as I said, I need to move the folder with this subfolder to a new folder.

Help me solve this problem.

Thanks.

+4
source share
1 answer

You can use apache-commons-io:

 org.apache.commons.io.FileUtils.copyDirectory(File, File) 
+11
source

Source: https://habr.com/ru/post/1343431/


All Articles