Skip to content

Commit

Permalink
FEAT ITEM-269-back-modifier-lordre-de-tri-du-fichier
Browse files Browse the repository at this point in the history
     - simplification du code de la méthode trierLignesDeCorrespondances() dans FichierPrepare.java
  • Loading branch information
EryneKL committed Oct 17, 2024
1 parent 4b8769a commit cb7d442
Showing 1 changed file with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,25 +122,16 @@ public void alimenterPpn(String input, String listeEpn, String rcr) {
public void trierLignesDeCorrespondances() throws IOException {
FileReader fileReader = new FileReader(path.resolve(filename).toString());
BufferedReader reader = new BufferedReader(fileReader);
List<String> correspondanceUnsortList = new ArrayList<>();
String result = null;
int i = 0;
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
if (i == 0) { // stockage de la ligne d'en-tête
result = line + "\n";
i++;
} else {
// stockage des lignes de correspondance
correspondanceUnsortList.add(line+"\n");
}
}

List<String> correspondanceSortList = new ArrayList<>();
String header = reader.readLine();//cette ligne enleve le header et le stock
correspondanceSortList.add(header + "\n");
reader.lines().sorted().forEach(line -> {
correspondanceSortList.add(line+"\n");
});
reader.close();
fileReader.close();
// tri des lignes
Collections.sort(correspondanceUnsortList);
// assemblage de l'en-tête avec les lignes pour constituer le résultat final
List<String> correspondanceSortList = new ArrayList<>(correspondanceUnsortList);
result = result + correspondanceSortList.toString().replaceAll(", ","").replaceAll("\\[", "").replaceAll("\\[", "").replaceAll("\\]", "").replaceAll("\\]", "");
String result = String.join("", correspondanceSortList);
ecrireFichierTrie(result);
}

Expand Down

0 comments on commit cb7d442

Please sign in to comment.