用正则表达式获取网页的email

来源:互联网 发布:诺基亚e71软件下载 编辑:程序博客网 时间:2024/05/18 01:07
public static void main(String[] args) {
  try {
   BufferedReader br=new BufferedReader(new FileReader("E:\\share\\10433633.html"));  //读取文件
   String line="";
   while(br.readLine() != null){
    Pattern p=Pattern.compile("[\\w[.-]]+@[\\w[.-]]+\\.[\\w]+");  //匹配email的表达式
    Matcher m=p.matcher(line);
    while(m.find()){
     System.out.println(m.group());   //分组打印出来
    }
   }
  } catch (FileNotFoundException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  }
 }