Search in sources :

Example 21 with CSVWriter

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;
}
Also used : CSVWriter(com.opencsv.CSVWriter) Writer(java.io.Writer) CSVWriter(com.opencsv.CSVWriter)

Aggregations

CSVWriter (com.opencsv.CSVWriter)21 OutputStreamWriter (java.io.OutputStreamWriter)7 FileOutputStream (java.io.FileOutputStream)5 FileWriter (java.io.FileWriter)5 File (java.io.File)4 Path (java.nio.file.Path)4 ArrayList (java.util.ArrayList)4 Entry (org.jbei.ice.storage.model.Entry)4 IOException (java.io.IOException)3 Writer (java.io.Writer)3 HashSet (java.util.HashSet)3 SPRTMethod (kr.ac.kaist.se.simulator.method.SPRTMethod)3 GroupController (org.jbei.ice.lib.group.GroupController)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 StringWriter (java.io.StringWriter)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ZipEntry (java.util.zip.ZipEntry)2 BaseChecker (kr.ac.kaist.se.mc.BaseChecker)2 Simulator (kr.ac.kaist.se.simulator.Simulator)2 EntryFieldLabel (org.jbei.ice.lib.dto.entry.EntryFieldLabel)2