抓取文件中的email邮箱

来源:互联网 发布:知乎登录界面 编辑:程序博客网 时间:2024/06/10 22:10
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 br = new BufferedReader(new FileReader("E:\\工作文件夹\\监察局\\shjjjc\\index.html"));
String line = "";
while ((line = br.readLine())!=null){
parse(line);

}

} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}


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


}
0 0
原创粉丝点击