Et oui c'est encore moi >< xD
J'ai effectué un programme qui parcourt entre 5 000 000 et 10 000 000 de fichier, et qui en fait une signature (MD5).
Le programme s'exécute sur une machine red hat.
J'ai donc créé une méthode qui exécute un commande linux : "md5sum /test/test/test" et je récupère le retour.
Je voulais savoir s’il y avait possibilité d'améliorer les performances de cette méthode, ou si il y a un tout autre moyen de faire ?
Merci d'avance,
Voilà ma méthode :
Merci !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 public static final String hashFile(String path) { String hashToReturn = ""; try { String algo = Constants.getHashAlgorithm(); // return "md5" String[] tmpPath = path.split(" "); String pathToUse = tmpPath[0]; String cmd = algo + "sum -b " + pathToUse; Process p = Runtime.getRuntime().exec(cmd); p.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; String tmp[]; while ((line = reader.readLine()) != null) { tmp = line.split(" "); hashToReturn = tmp[0]; } reader.close(); p.destroy(); } catch (Exception e) { System.out.println("Problem hashing file ! (" + path + ")"); if (hashToReturn.equals("")) { hashToReturn = "notHashed"; } } return hashToReturn; }
Partager