Import java.io.*
Import java.net.*
/**
* <p>title: Get a URL text </p>
* <p> Description: Constructs an input object and reads its contents by using the URL class. </p>
* <p>copyright:copyright (c) 2003</p>
* <P>FILENAME:GETURL.JAVA</P>
* @ Version 1.0
*/
public class geturl{
public static void Main (string[] arg) {
if (arg.length!=1) {
Syste M.OUT.PRINTLN ("Use Java getURL url");
return;
}
New GetURL (arg[0]);
}
/**
*<br> Method Description: Constructor
*<br> input parameter: String URL Web page address.
*<br> return Type:
*/
Public GetURL (String URL) {
try {
//Create a URL object
URL url = new url (URL) ;
//Read all text returned from the server
BufferedReader in = new BufferedReader (New InputStreamReader (Url.openstream ());
String str;
while (str = In.readline ())!= null) {
//Here is the text out of
display (str);
}
In.close ();
{} catch (Malformedurlexception e) {
} catch (IOException e) {
}
}
/**
*<br> Method Description: Display information
*<br> input parameters:
*<br> return type:
*/
Private void display (String s) {
if (s!=null)
System.out.println (s);
}
}