Crawling URLs with JSP

Source: Internet
Author: User
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 );
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.