/******************************************************************************************************* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************************************************/ /********************************************************************** * Ce programme permet d'extraire la totalité des emails existants dans un * fichier texte nommé Myfile.txt et gener deux fichiers Resultat.txt & NonTrier.txt * Créer Par: D3vDiL Merci à : Usr[Denied] * Nom fichier : extract.java * version: 0.1 *********************************************************************/ import java.io.*; import java.util.*; import java.util.regex.*; class extract{ public static void main(String[] arg){ // ouverture du fichier BufferedReader IN=null; try { IN=new BufferedReader(new FileReader("myfile.txt")); } catch (Exception e) { Erreur(e,1); } // ouverture du fichier temp pour enregistré PrintWriter temp=null; try{ temp=new PrintWriter(new FileWriter("NonTrier.txt"),true); } catch (Exception e){ Erreur(e,2); } String ligne=null; Pattern pattern; Matcher matcher; int line=0; // parcoure du fichier qui contient les emails try { while((ligne=IN.readLine())!=null) { // Correspondent à l'adresse email pattern = Pattern.compile("[a-z0-9\\-_\\.]++@[a-z0-9\\-]++(\\.[a-z0-9\\-]++)++"); Matcher mail = pattern.matcher(ligne); int gc = mail.groupCount(); while(mail.find()){ for (int i=0; i