简体   繁体   English

Java下载文件,带有带有进度条的Apache IO

[英]Java Download File With Apache IO with Progress Bar

Basically, I'm trying to find a way to download files with Java Apache IO Commons and have a swing progress bar. 基本上,我试图找到一种使用Java Apache IO Commons下载文件并具有进度条的方法。 I know how to download URL to file, using FileUtils.copyUrlToFile(); 我知道如何使用FileUtils.copyUrlToFile();将URL下载到文件FileUtils.copyUrlToFile(); and such, but how would I add a progress bar? 等等,但是我将如何添加进度栏?

IO 2.0和更高版本的Commons确实具有copyInputStreamToFile(InputStream源,File目标) ,因此您可以使用ProgressMonitorInputStream。

Since none of the methods of FileUtils accept an InputStream we can't use ProgressMonitorInputStream , and I can't see any other way into that API that would give info. 由于FileUtils任何方法都不接受InputStream我们不能使用ProgressMonitorInputStream ,而且我也看不到该API中提供信息的任何其他方式。 on progress, I think this idea is a non-starter. 就进展而言,我认为这个想法是一个初学者。 It cannot be done. 无法完成。

Unless you are referring to copying multiple resources from URL (s) to File (s), then we could at least offer the progress of the group (eg "3 out of total of 5 files copied"). 除非您是指将多个资源从URL复制到File ,否则我们至少可以提供组的进度(例如,“复制的5个文件中有3个”)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM