我必须读取一个文件夹,计算该文件夹中的文件数量(可以是任何类型),显示文件数量,然后将所有文件复制到另一个文件夹(指定)。
我该如何进行?
最佳答案
i Have to read a folder, count the number of files in the folder (can be of any type) display the number of files
您可以在 java.io.File
的 javadoc 中找到所有这些功能。
and then copy all the files to another folder (specified)
这有点棘手。阅读:Java Tutorial > Reading, Writing and Creating of Files (请注意,其中描述的机制仅在 Java 7 或更高版本中可用。如果 Java 7 不是一个选项,请参阅以前的许多类似问题之一,例如这个: Fastest way to write to file? )
关于Java:如何读取目录文件夹,计算并显示文件数量并复制到另一个文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13045326/