I have a problem when I want to download file from internet in java. I try to used something like this:
String stringUrl = "http://imageshack.us/a/img841/7762/formd.png";
File file = new File("");
try {
URL url = new URL(stringUrl);
FileUtils.copyURLToFile(url, file);
}
but I got an I/O exception. What is the best way to download file from internet and put it into 'File' object?
1<<24value. It'll work fine in this case because it's a simple image, but for most cases where you don't really know or want to guess the file size, I'd just useLong.MAX_VALUE. FWIW, I tihnk this Apache Commons approach is neater.