Listing B
import java.net.*;
import java.io.*;
 
public void readFromURL()
{
   try
   {
      URL url = new URL("http://www.mycompany.com");
      URLConnection connection = url.openConnection();
      connection.setDoInput(true);
      InputStream inStream = connection.getInputStream();
      BufferedReader input =
         new BufferedReader(new InputStreamReader(inStream));
 
      String line = "";
      while ((line = input.readLine()) != null)
         System.out.println(line);
   }
   catch (Exception e)
   {
      System.out.println(e.toString());
   }
}