package net.oschina.tester;
import java.io.File;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.io.FileUtils;
/**
* 提取邮件地址
* @author Winter Lau
* @date 2010-6-14 下午04:56:15
*/
public class EmailParser {
private final static Pattern emailer = Pattern.compile("\\w+?@\\w+?.com");
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
String txt = FileUtils.readFileToString(new File(args[0]));
//System.out.println(txt);
Matcher matchr = emailer.matcher(txt);
while (matchr.find()) {
String email = matchr.group();
System.out.println(email);
}
}
}
转自:http://www.oschina.net/code/snippet_12_544