I self learn Java, and I am trying to do some programs for work. As in the title, the Table looks fine. But when I export to Csv only the last element is saved.
I must have made a mistake somewhere. Your help will be strongly appreciated.
public void listInsideFolder(String nomFile) throws Exception {
File file = new File(nomFile);
File[] listOfFiles = file.listFiles();
List<String> Adresses = new ArrayList<>();
List<String> Names = new ArrayList<>();
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
Adresses.add(listOfFiles[i].getAbsolutePath());
Names.add(listOfFiles[i].getName());
}
StringColumn column0 = StringColumn.create("Names", Names);
StringColumn column1 = StringColumn.create("Addresses",Adresses);
Table t = Table.create();
t.addColumns(column0);
t.addColumns(column1);
// System.out.println(t);
// System.out.println(column0);
// System.out.println(Names);
t.write().csv("C:\\Users\\user\\Desktop\\Dossier\\Floweriest.csv");
Adresses.clear();
Names.clear();
t.clear();
column0.clear();
column1.clear();
}
}