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

class GetWebPage
{
    public static void main( String [] args )
    {
        if( args.length != 1 )
        {
            System.out.println( "Need a machine" );
            return;
        }

        String remoteMachine = args[ 0 ];
        System.out.println( "Connecting to " + remoteMachine );

        try
        {
            URL url = new URL( remoteMachine );
            URLConnection urlconn = url.openConnection( );
            
            String str = null;
            if( urlconn.getContent( ) instanceof InputStream )
            {
                BufferedReader in = new BufferedReader( 
                            new InputStreamReader( urlconn.getInputStream( ) ) );

                while( ( str = in.readLine( ) ) != null )
                    System.out.println( str );
            }
            else
            {
                System.out.print( "Site does not contain text; the content is " );
                System.out.println( url.getContent().getClass().getName());
            }
        }
        catch( IOException e )
        {
            System.out.println( e );
        }
    }
    
}
