CJ Burkey
CJ Burkey

Reputation: 385

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. I know how to download URL to file, using FileUtils.copyUrlToFile(); and such, but how would I add a progress bar?

Upvotes: 1

Views: 2118

Answers (2)

eduardog3000
eduardog3000

Reputation: 81

Commons IO 2.0 and above do have copyInputStreamToFile(InputStream source, File destination), so you can use ProgressMonitorInputStream.

Upvotes: 4

Andrew Thompson
Andrew Thompson

Reputation: 168845

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. 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 (e.g. "3 out of total of 5 files copied").

Upvotes: 2

Related Questions