本文介绍了带有 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:

  1. 找到您要复制的所有文件,然后先计算数量或总文件大小(取决于您的进度条应该测量什么)
  2. 使用 FileUtils.copyDirectory(File, File, FileFilter) 并滥用"FileFilter 作为将进度传达给进度条的回调
  1. 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)
  2. Copy the files using FileUtils.copyDirectory(File, File, FileFilter) and "abuse" the FileFilter as a callback to communicate progress to your progress bar

这篇关于带有 Apache FileUtils.copyDirectory(...) 的进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 08:33