import java.io.*; import java.net.*; public class Downloader { // small HTTP (web) client similar to wget program private static void download(String url) throws Exception { URL myURL = new URL(url); // getFile() ==> filename URLConnection myConn = myURL.openConnection(); // 1KB = 1024 Bytes (1 Byte = 8 bits) double totalSize = myConn.getContentLength(); // network reader InputStream netIn = myURL.openStream(); String fname = myURL.getFile(); System.out.println("downloading " + fname); } public static void main(String[] args) throws Exception { String url = "http://www.cs.gettysburg.edu/~skim/cs112/hws/hw3/Cat.gif"; download(url); //new Downloader().download(url); // if download(..) is not static } }