Java:如何读取目录文件夹,计数和显示没有文件,并复制到另一个文件夹? [英] Java: How to read directory folder, count and display no of files and copy to another folder?

查看:211
本文介绍了Java:如何读取目录文件夹,计数和显示没有文件,并复制到另一个文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须读取一个文件夹,计算文件夹中的文件数量(可以是任何类型),显示文件数量,然后将所有文件复制到另一个文件夹(指定)。

I have to read a folder, count the number of files in the folder (can be of any type), display the number of files and then copy all the files to another folder (specified).

我将如何进行?

推荐答案


我必须读取一个文件夹,计算文件夹中的文件数b $ b为任何类型)显示文件数

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


然后将所有文件复制到另一个文件夹

and then copy all the files to another folder (specified)

这有点棘手。阅读: Java教程>文件的读取,写入和创建
(请注意,这里描述的机制仅在Java 7或更高版本中可用。如果Java 7不是一个选项,请参考前面类似的问题之一,例如:最快的方式写入文件?

This is a bit more tricky. Read: Java Tutorial > Reading, Writing and Creating of Files (note that the mechanisms described there are only available in Java 7 or later. If Java 7 is not an option, refer to one of many previous similar questions, e.g. this one: Fastest way to write to file? )

这篇关于Java:如何读取目录文件夹,计数和显示没有文件,并复制到另一个文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆