public class EmailSpider
{
public static void main(String[] args)
{
try
{
BufferedReader br = new BufferedReader(new FileReader(
"D:\\test.txt"));
String line = "";
BufferedWriter bfw = new BufferedWriter(new FileWriter("D:\\t.txt"));
while ((line = br.readLine()) != null)
{
bfw.write(parse(line));
bfw.newLine();
}
bfw.flush();
bfw.close();
} catch (FileNotFoundException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
}
}
private static String parse(String line)
{
Pattern p = Pattern.compile("[\\w[.-]]+@[\\w[.-]]+\\.[\\w]+");
Matcher m = p.matcher(line);
StringBuffer buf = new StringBuffer();
while (m.find())
{
System.out.println(m.group());
buf.append(m.group());
}
return buf.toString();
}
}
Email格式验证
最新推荐文章于 2021-09-29 14:37:25 发布