如何使用Java代码将文件夹(包括子目录和文件)移动到新文件夹中 [英] How to move a folder(including subdirectories and files) into a new folder using Java code
问题描述
例如:
我有一个名为 temp
的文件夹,里面 temp
我有一个文件夹 in-temp
。
我想要将我的 temp
文件夹复制或移动到名为的新文件夹中新的temp
,但是使用Java代码。
我通过在Google上搜索一个示例代码,将文件夹的副目录和文件复制到新文件夹中,但是像说我需要移动将一个文件夹的子文件夹移动到一个新文件夹中。
帮我解决这个问题。 b
$ b
谢谢。
您可以使用apache-commons-io:
org.apache.commons.io.FileUtils.copyDirectory(File,File)
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.
You can use apache-commons-io:
org.apache.commons.io.FileUtils.copyDirectory(File, File)
这篇关于如何使用Java代码将文件夹(包括子目录和文件)移动到新文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!