
/**
 * demonstration of simple access to World Wide Web
 */

import java.io.* ;
import java.net.* ;

public class Chapter19n8
    {
    public static void main(String[] args) throws Exception
	{
        BufferedReader din =
			new BufferedReader(new InputStreamReader(System.in)) ;

	System.err.print("URL? ") ;
	System.err.flush() ;
	String urlString = din.readLine().trim() ;

	try {
	    System.err.println("**attempting connection**") ;
	    URL s = new URL(urlString) ;
	    System.err.println("**made connection**") ;

            BufferedReader s1 =
		new BufferedReader(new InputStreamReader(s.openStream())) ;

	    System.err.println("**START OF INPUT**") ;
	    while (true)
		{
		String line = s1.readLine() ;
		if (line == null)
		    break ;
		System.out.println(line) ;
		}
	    System.err.println("**END OF INPUT**") ;
	    }
        catch(IOException e)
	    {
	    System.err.println("ERROR: " + e) ;
	    }
	} // end of main method
    } // end of class Chapter19n8

