Import java. io .*;
Import java.net .*;
Import java. util .*;
Class url2htm {
Static private url2htm instance; // Create the only instance of the class
Public static String strURL = ""; // Announce the universial variable to mark the destination URL
Public static String strFile = ""; // Announce the universial variable to mark the local file path
/**
* Construct the private function to prevent other
* Application from creating the instance of this class
*/
Private url2htm (){
Init ();
}
/**
* The main function that will invoke the application
*/
Public static void main (String args []) {
Url2htm instUrl2htm = new url2htm (); // Create the instance of the default class
InstUrl2htm. write (); // Invoke the chief function
}
/**
* The setProperties () function will set the two major
* Variables to the class
* @ Para propNames
* @ Para name
*/
Private void setProperties (Properties props ){
Enumeration propNames = props. propertyNames ();
While (propNames. hasMoreElements ()){
String name = (String) propNames. nextElement ();
If (name. endsWith (". url ")){
String webName = name. substring (0, name. lastIndexOf ("."));
StrURL = props. getProperty (webName + ". url ");
StrFile = props. getProperty (webName + ". file ");
}
}
}
/**
* The getURL () function will return the URL string
*/
Private void getURL (){
System. out. println (strURL );
}
/**
* The getFile () function will return the local file and path
*/
Private void getFile (){
System. out. println (strFile );
}
/**
* The write () function will read the dest URL as input stream and
* Write into a local file
* @ Para fileline
* @ Para url
*/
Private static void write (){
String fileline;
String url = strURL;
Try {
URL destURL = new URL (url );