获取网页上的邮箱地址

来源:互联网 发布:软件开发计划模板 编辑:程序博客网 时间:2024/05/17 02:51
 

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class EmailSpider {

 public static void main(String[] args) {
    try {
  BufferedReader buf =new BufferedReader(new FileReader("G:\\NHK.htm"));
  String str="";
  while((str=buf.readLine())!=null){
   
   parsin(str);
  }
 } catch (FileNotFoundException e) {
  e.printStackTrace();
 } catch (IOException e) {
  e.printStackTrace();
 }
 }

 private static void parsin(String str) {
    Pattern p = Pattern.compile("[\\w]+@[\\w]+\\.[\\w]+");
    Matcher m = p.matcher(str);
   
    while(m.find()){
    
     System.out.println(m.group());
    
    }
  
 }

}

原创粉丝点击