本文介绍了带有Apache FileUtils.copyDirectory(...)的进度栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人知道如何为Apache FileUtils.copyDirectory(File src, File dst)
实现进度条吗?在 JavaDocs 和API.似乎是处理批处理磁盘操作中的一个常见用例,所以我不确定是否错过了明显的事情.
Does anyone know any way of implementing progress bar for Apache's FileUtils.copyDirectory(File src, File dst)
? I don't see anything helpful in JavaDocs and API. Seems like a common use case in dealing with batch disk operations, so I'm not sure if I miss something obvious.
推荐答案
我想您将不得不自己做.我看到了立即解决方案:
I guess you will have to do that yourself. I see this immediate solution:
- 找到要复制的所有文件,然后首先计算数量或文件总大小(取决于进度条应测量的大小)
- 使用
FileUtils.copyDirectory(File, File, FileFilter)
并滥用"FileFilter
作为回调,以将进度传达给进度条
- Find all files you are about to copy and count the number or total file size first (depending on what your progress bar should measure)
- Copy the files using
FileUtils.copyDirectory(File, File, FileFilter)
and "abuse" theFileFilter
as a callback to communicate progress to your progress bar
这篇关于带有Apache FileUtils.copyDirectory(...)的进度栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!