熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

從outlook導入email地址

2022-06-13   來源: JSP教程 

  outlook有一種email地址格式采用逗號分隔開字段擴展名叫CSV
  例如
  姓名稱謂單位名稱部門職務郵政地址郵政編碼電話傳真統一編碼其他電話單位其他移動電話呼機主頁電子郵件備注
  
  下面寫個程序打開csv文件每行讀取只用第一個逗號前的字符串作為姓名email地址匹配格式取第一個(位置無關)粗陋程序如下
  
   private static final String repmail =([\\w]+[@]{}((\\w)+[]){}(\\w)+);
   private static final String repname =+?;
   Pattern mailPattern = pile(repmail );
   Pattern namePattern = pile(repname);
   File file = new File(testCSV);
   FileInputStream is = new FileInputStream(file);
   BufferedReader br = new BufferedReader(new InputStreamReader(is));
      String input = null;
   ArrayList list = new ArrayList();
    while((input = brreadLine())!=null){
    Matcher matchermail = mailPatternmatcher(input);
    Matcher matchername = namePatternmatcher(input);
    String[] card = new String[];
    if(matchernamefind()){
     card[] = matchernamegroup()replaceAll(\);
    }
      if(matchermailfind()){
       card[] = matchermailgroup();
    }
    if(card[]==null || card[]equals() || card[]==null || card[]equals()){
     continue;
    }
    listadd(card);
   }//輸出 for(int i=;i
       Systemoutprintln(((String[])listget(i))[] + : + ((String[])listget(i))[]);
   }
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19751.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.