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

岁酱吖の 提交于 2020-01-01 05:49:08

问题


Can anyone help me for a Java code which copy or move one folder as it is into another folder.

For example:
I have a folder named temp, inside temp I have a folder in-temp.

I want that my temp folder should be copied or moved into a new folder named new temp, but by using Java code.

I got an example code by searching on Google which copies the sub-directories and files of a folder into a new folder, but as I said I need to move a folder with it's sub-folder into a new folder.

Help me to resolve this.

Thank you.


回答1:


You can use apache-commons-io:

org.apache.commons.io.FileUtils.copyDirectory(File, File)


来源:https://stackoverflow.com/questions/5282177/how-to-move-a-folderincluding-subdirectories-and-files-into-a-new-folder-using

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!