Source of URLReader.java


  1: import java.util.Scanner;
  2: import java.io.InputStreamReader;
  3: import java.io.DataOutputStream;
  4: import java.net.URL;
  5: 
  6: public class URLReader
  7: {
  8:     public static void main(String[] args) throws Exception {
  9: 
 10:     URL website = new URL("http://www.wikipedia.org");
 11:     Scanner inputStream = new Scanner(
 12:                 new InputStreamReader(website.openStream()));
 13: 
 14:     while (inputStream.hasNextLine())
 15:     {
 16:      String s = inputStream.nextLine();
 17:      System.out.println(s);
 18:     }
 19:     inputStream.close();
 20:   }
 21: }