use of com.opencsv.CSVWriter in project Energieverbrauchssimulator by duschdas2.
the class Create_CSV method create.
/**
* Erstellt eine CSV_Datei aus dem übergebenden Daten
* @param data
* @return
* @throws IOException
*/
public static String create(String[][] data) throws IOException {
String path = date_time();
try (Writer writer = Files.newBufferedWriter(Paths.get(path));
CSVWriter csvWriter = new CSVWriter(writer, ';', CSVWriter.NO_QUOTE_CHARACTER, CSVWriter.DEFAULT_ESCAPE_CHARACTER, CSVWriter.DEFAULT_LINE_END)) {
for (int i = 0; i < data.length; i++) {
String[] tmp = new String[data[i].length];
for (int c = 0; c < data[i].length; c++) {
// System.out.print(data[i][c] + ", ");
tmp[c] = data[i][c];
}
// System.out.println();
csvWriter.writeNext(tmp);
}
}
return path;
}
Aggregations