zoukankan      html  css  js  c++  java
  • java使用正则从爬虫爬的txt文档中提取QQ邮箱

    我的需求是从一堆文档中提取出qq邮箱,写了这篇帖子,希望能帮助和我有一样需求的人,谢谢!......


    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileReader;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
     
    public class GetEmail {
    public static void getEmail() {
            File file = new File("E://itxm/email.txt");
            try{
                BufferedReader br = new BufferedReader(new FileReader(file));//构造一个BufferedReader类来读取文件
                String s = null;
                while((s = br.readLine())!=null){//使用readLine方法,一次读一行
                  Pattern pattern = Pattern.compile("[^0-9]");
                  Matcher matcher = pattern.matcher(s);
                  String email = matcher.replaceAll("");
                  if(!"".equals(email)&&email.length()>5){
                   System.out.println(email+"@qq.com");
                  }
                }
                br.close();
            }catch(Exception e){
                e.printStackTrace();
            }
    }
     
    public static void main(String[] args) {
        getEmail();
    }
    }
  • 相关阅读:
    automatic preferred max layout width
    UIActivityIndicatorView
    collectionview不能拖动
    消除找不到文件路径的警告
    保存图片到本地和相册
    svn上传.a文件
    UILabel copyWithZone:]: unrecognized selector sent to instance 0x7fd662d8f9b0
    NSString NSURL
    iOS 定位功能
    前端实现左右翻页功能Demo
  • 原文地址:https://www.cnblogs.com/wangyayun/p/6052563.html
Copyright © 2011-2022 走看看