//URLReader.java

import java.util.Scanner;
import java.io.InputStreamReader;
import java.net.URL;

public class URLReader
{
    public static void main(String[] args) throws Exception
    {
        URL website = new URL("http://cs.smu.ca/webbook2e/ch02/first.txt");
        Scanner inputStream = new Scanner(
            new InputStreamReader(website.openStream()));

        while (inputStream.hasNextLine())
        {
            String s = inputStream.nextLine();
            System.out.println(s);
        }
        inputStream.close();
        Scanner keyboard = new Scanner(System.in);
        System.out.print("Press Enter to continue ... ");
        keyboard.nextLine();
    }
}

