// Allison Obourn // CSE 143, Autumn 2015 // This program uses the Downloader class to download a web page // from a URL and save it to a file on the local hard disk. // It also demonstrates the exception try/catch syntax for handling errors. import java.io.*; import java.net.*; import java.util.*; public class DownloadMain { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.println("URL to download? "); String url = console.nextLine(); Downloader down = null; while(down == null) { try { down = new TallyDownloader(url); } catch (MalformedURLException e) { System.out.println("bad URL please try again "); url = console.nextLine(); } } System.out.println("Target file name? "); String target = console.nextLine(); try { down.download(target); } catch (IOException e) { System.out.println(e.getMessage()); } } }