/*网络爬虫--爬邮件*/
import java.io.*;
import java.util.regex.*;
class Main {
public static void main(String[] args) throws Exception {
getMails();
}
public static void getMails() throws Exception {
BufferedReader bufr = new BufferedReader(new FileReader("mail.txt"));
String line = null;
String mailreg = "\\w+@\\w+(\\.\\w+)+";
Pattern p = Pattern.compile(mailreg);
while((line=bufr.readLine())!=null) {
Matcher m = p.matcher(line);
while(m.find())
System.out.println(m.group());
}
}
}
原文地址:http://blog.csdn.net/sjtu_chenchen/article/details/45373825