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 Test {
public static void main(String[] args) {
try {
BufferedReader br = new BufferedReader(new FileReader("D:\\新建文本文档 (2).txt")); //跟据本地文件夹
String line ="";
while((line=br.readLine())!=null){
parse(line);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
private static void parse(String line) {
Pattern p = Pattern.compile("[\\w[.-]][email protected][\\w[.-]]+\\.[\\w]+"); //根据正则表达式 表示邮件的形式
Matcher m = p.matcher(line);
while(m.find()){
System.out.println(m.group());
}
}
}