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