import java.net.URL;
import java.net.MalformedURLException;
import java.io;

public class URLDemo2
{
  public static void main(String[] args)
  {
    try
    {
	if (args.length != 1)
	{
	  System.out.println("Usage: java URLDemo2 <url>");
	  System.exit(1);
	}

	URL url = new URL(args[0]);

	//get contents of an URL
	InputStream inStream = url.openStream();
	BufferedInputStream buffer = new BuffereInputStream(inStream);
	int ch;
	while((ch = buffer.read()) != -1)
	{
	  System.out.print((char)ch);
	}

	buffer.close();
     }
     catch(MalformedURLException malformE)
     (
	System.out.println(malformE);
     )
     catch(IOException ioE)
     {

	System.out.println(ioE);
     }
   }
}
