Extraire des informations a partir d'un fichier texte

Fermé
khouloud - Modifié par KX le 31/03/2016 à 19:34
Bonjour,


je veux resoudre un probleme j'ai un fichier texte ceci:
ligne0=2016-01-03 10:21:31 - #####################################################################
ligne1=2016-01-03 10:21:31 - Found 2 entries to process
ligne2=2016-01-03 10:21:31 - #####################################################################
ligne3=2016-01-03 10:21:31 - ---------------------------------------------------------------------
ligne4=2016-01-03 10:21:31 - Processing LabelID <4670102> of type <20211>
ligne5=2016-01-03 10:21:32 - Found <232> data values to be substituted on bookmark
ligne6=2016-01-03 10:21:32 - Sending count of <1> labels to printer <PRP13A011>
ligne7=2016-01-03 10:21:32 - Start Printing of LabelID <4670102> for file <C:\Program Files\MAR GmbH\PMS.Printprocessor\Templates\20211.dot>, <1> times, with count of <232> bookmarks on printer <PRP13A011>
ligne8=2016-01-03 10:21:32 - Printing of 40004030629MR.
ligne9=2016-01-03 10:21:42 - Printing of LabelID completed.
ligne10=2016-01-03 10:21:42 - ---------------------------------------------------------------------
ligne11=2016-01-03 10:21:42 - Timer Wait2

je vais extraire les informations l'importante date et temps et <PRP13A011> mais en utilisant les expressions reguliers est ce que il y a quelqu'un qui peut m'aider ?
voici mon code :
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Projetjava {  
    
    
     public static void lecture(){
        
        String chaine;
 chaine = "data[i]";
  Pattern p = Pattern.compile("PRP\\d\\d\\w\\d\\d\\d");
  Matcher m = p.matcher("data[i] ");
  while(m.find()) {
   System.out.println(m.group(0));
   
  }
    
    }
    public static void printerName() throws IOException{
        int k=0;
        int z=0;
        String ligne;
        
       String []data=new String [700];
        
        
               String pathFile="Files/PMS.PrintProcessor_20160103.txt"; //chemin du notre fichier
        
        //Functions f1=new Functions();  
      data= readFile(pathFile) ; // maintenant le tableau data contient tout le fichier
        
        
      for (int i=0; i<data.length; i++){
          
      ligne=data[i];//les lignes des fichiers
      
      System.out.println("ligne"+i+"="+ligne); //affichage des lignes
 
      }
    }
 
    
     public static String[] readFile(String pathFile) throws IOException{

  BufferedReader in = null; //in c'est le nom du bufferreader  
  int x=0;

  String line;
  
  String [] data1 =new String[633];

  try {
   in = new BufferedReader ( new FileReader ( pathFile) );
  } catch (FileNotFoundException e) {
   
   e.printStackTrace();
  }

  
  while ( ( line = in.readLine()) != null )
  {

   data1[x]=line;//x est un index ligne par ligne c'est un compteur comme i
   x++;
  } 
  
  in.close();    


  return data1;

        }

}


merci beaucoup pour votre aide