读书人

获取资料中邮件的示例

发布时间: 2012-10-28 09:54:44 作者: rapoo

获取文件中邮件的示例

import java.util.regex.*;import java.io.*;class  GetMails{public static void main(String[] args) throws IOException{getMail();}public static void getMail()throws IOException{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());}}}}

?

读书人网 >编程

热点推荐