Download file using java apache commons?
Posted
by
Kyle
on Stack Overflow
See other posts from Stack Overflow
or by Kyle
Published on 2011-01-15T07:39:41Z
Indexed on
2011/01/15
7:54 UTC
Read the original article
Hit count: 258
How can I use the library to download a file and print out bytes saved? I tried using
import static org.apache.commons.io.FileUtils.copyURLToFile;
public static void Download() {
URL dl = null;
File fl = null;
try {
fl = new File(System.getProperty("user.home").replace("\\", "/") + "/Desktop/Screenshots.zip");
dl = new URL("http://ds-forums.com/kyle-tests/uploads/Screenshots.zip");
copyURLToFile(dl, fl);
} catch (Exception e) {
System.out.println(e);
}
}
but I cannot display bytes or a progress bar. Which method should I use?
© Stack Overflow or respective owner