Java program that captures the e-mail address in a webpage File

Source: Internet
Author: User

 

We can first download a webpage file on our own hard disk, then read the file through the URL address, and use this expression to compare whether the read string is an email address to capture it! The legend is that spam first crawls others' email addresses on the webpage. The specific applet is as follows:

Import java. Io. bufferedreader;
Import java. Io. filenotfoundexception;
Import java. Io. filereader;
Import java. Io. ioexception;
Import java. util. RegEx. pattern;
Import java. util. RegEx .*;

Public class spider {

Public static void main (string [] ARGs ){
Try {
Bufferedreader Buf = new bufferedreader (New filereader ("F: \ A. MHT "));
String line = "";
While (line = Buf. Readline ())! = NULL)
Pattern (line );
} Catch (filenotfoundexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
} Catch (ioexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
}
}

Private Static void pattern (string line ){
Pattern P = pattern. compile ("[\ W [. _] + @ [\ W [. _] + \\. [\ W] + "); // Regular Expression of the email address;
Matcher M = P. matcher (line );
While (M. Find ()){
System. Out. println (M. Group ());
}
/* While (P. matcher (line )! = NULL ){

}*/

}

}

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.