In this section we cover and explain Download a WebPage in details for freshers and experienced
previous | Home | Next |
Example
import java.net.*; import java.io.*; public class ABC { public static void main (String args[]) { String thisLine; URL u; if (args.length > 0) { //Open the URL for reading try { u = new URL(args[0]); // now turn the URL into a DataInputStream try { DataInputStream html = new DataInputStream(u.openStream()); try { while ((thisLine = html.readLine()) != null) { System.out.println(thisLine); } // while loop ends here } // end try catch (Exception e) { System.err.println(e); } } // end try catch (Exception e) { System.err.println(e); } } // end try catch (MalformedURLException e) { System.err.println(args[0] + " is not a parseable URL"); System.err.println(e); } } // end if } // end main } // end viewsource
previous | Home | Next |