è un articolo trovato proprio su html.itcodice:import java.io.*; import java.net.MalformedURLException; import java.net.URL; public class getPage { public getPage() { } public static void main(String args[]) { String s; try { s = args[0]; } catch(ArrayIndexOutOfBoundsException arrayindexoutofboundsexception) { s = "http://www.html.it/index.asp"; System.out.println("Nessun URL definito, prendo " + s); } System.out.println("URL:" + s); boolean flag = false; URL url = null; try { url = new URL(s); } catch(MalformedURLException malformedurlexception) { System.out.println("URL errato, prendo http://www.html.it/index.asp "); flag = true; } if(flag) try { url = new URL("http://www.html.it/index.asp "); } catch(MalformedURLException malformedurlexception1) { } BufferedReader bufferedreader; try { bufferedreader = new BufferedReader(new InputStreamReader(url.openStream())); } catch(IOException ioexception) { System.out.println("Errore di apertura del file"); return; } File file = new File(".\\" + url.getFile()); FileWriter filewriter; try { filewriter = new FileWriter(file); } catch(IOException ioexception1) { return; } try { String s1; while((s1 = bufferedreader.readLine()) != null) filewriter.write(s1); filewriter.flush(); filewriter.close(); } catch(IOException ioexception2) { System.out.println("Errore di lettura."); return; } }
![]()