Download a File With Java and Apache Commons Io Api
To make this code works you need: 1.) http://commons.apache.org/io/download_io.cgi 2.) make sure to configure your build path and include th...

package org.ipiel.tools.friendster.downloader; import java.io.*; import java.net.URL; import org.apache.commons.io.FileUtils; public class PhotoDownloader { public static void main(String args[]) { new PhotoDownloader(); } public PhotoDownloader() { try { BufferedReader lineReader = new BufferedReader(new FileReader("input/input.txt")); String line = ""; int ctr = 1; while((line = lineReader.readLine()) != null) { URL u = new URL(line); String output = line.substring(line.lastIndexOf('/') + 1); System.out.println((ctr++) + " Downloading: " + output); FileUtils.copyURLToFile(u, new File(output)); } } catch(IOException e) { e.printStackTrace(); } } }One piece of advice, don't try creating your own class :-D, it's already done :-D. Thanks to the apache boys they always make my code simple :-D Well you might ask, how can I do this in C#? Read this link http://czetsuya-tech.blogspot.com/2010/03/download-image-given-url-in-c-using.html
Post a Comment