1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
public class resumeLog{
//attributs
private static PrintWriter fluxSortie;
private static HashMap<String,String> filesNamesPaths ;
private static File folder;
/*private static int rating;*/
/**
* @param args
* @throws FileNotFoundException
*/
public static void main(String[] args) throws FileNotFoundException {
// TODO Auto-generated method stub
//récupérer la liste des path des fichiers textes dans une HashMap
folder = new File("input/traces");
File[] listOfFiles = folder.listFiles();
filesNamesPaths = new HashMap<String,String>();
for (File file : listOfFiles) {
if (file.isFile()) {
filesNamesPaths.put(file.getName(),file.getPath());
System.out.println(filesNamesPaths.put(file.getName(),file.getPath()));
}
}
//Parcourir la HashMap et effectuer les traitements
for(Entry<String, String> entry : filesNamesPaths.entrySet()) {
fluxSortie = new PrintWriter(new FileOutputStream("output/Traces/trace"+entry.getKey()));
File file = new File(entry.getValue());
Scanner scanner = new Scanner(file,"ISO-8859-1");
while (scanner.hasNextLine()) {
String currentLine = (String) scanner.nextLine();
if(currentLine.startsWith(" Start:") || currentLine.startsWith("Start:") || currentLine.startsWith(" End:") || currentLine.startsWith("End:")){
fluxSortie.print(filesNamesPaths.put(file.getName(),"")+" " +currentLine);
}
}
fluxSortie.close();
scanner.close();
}
System.out.println("Fin d'éxecution");
}
} |
Partager