

import java.io.*;       //   NEW, for URL
import java.net.*;       //   NEW, for URL


public class URLExample
    {
	  public static void main(String args[])
        {

		  String url_name = "http://www.nmu.edu";
		  try
		   {
			  PrintWriter outfile;
			  outfile = new PrintWriter(new FileOutputStream("test.html"));


		  	  URL urlobj = new URL(url_name);
		  	  InputStream in = urlobj.openStream();
		  	  BufferedReader br = new BufferedReader(new InputStreamReader(in));

		  	  String s;
		  	  while( (s=br.readLine()) != null)
		  	       {
		  	        System.out.println(s);
		  	        outfile.println(s);
				   }
			  br.close();
			  outfile.close();

		     }
 		   catch (Throwable anError)
 		     {
		    	 System.out.println("outfile error>  " + anError); // display the error
		     }
	     }

    }