use of au.com.bytecode.opencsv.CSVWriter in project flowml by beautifulNow1992.
the class CsvTableRenderer method render.
@Override
public void render(Writer w, int indent) {
TableModel tableModel = textTable.getTableModel();
try (CSVWriter csvWriter = new CSVWriter(w)) {
String[] headers = new String[tableModel.getColumnCount()];
for (int i = 0; i < headers.length; i++) {
headers[i] = tableModel.getColumnName(i);
}
csvWriter.writeNext(headers);
for (int i = 0; i < tableModel.getRowCount(); i++) {
String[] line = new String[tableModel.getColumnCount()];
for (int j = 0; j < tableModel.getColumnCount(); j++) {
Object valueAt = tableModel.getValueAt(i, j);
line[j] = String.valueOf(valueAt);
}
csvWriter.writeNext(line);
}
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
use of au.com.bytecode.opencsv.CSVWriter in project mica2 by obiba.
the class CsvReportGenerator method write.
public void write(OutputStream outputStream) {
try (CSVWriter writer = new CSVWriter(new PrintWriter(outputStream))) {
writeHeader(writer);
writeSummary(writer);
writeEachDataAccessRequest(writer);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of au.com.bytecode.opencsv.CSVWriter in project mica2 by obiba.
the class CsvPersonsWriter method write.
public ByteArrayOutputStream write(Mica.PersonsDto persons) throws IOException {
ByteArrayOutputStream values = new ByteArrayOutputStream();
CSVWriter writer = null;
try {
writer = new CSVWriter(new PrintWriter(values));
writer.writeNext(headers.toArray(new String[headers.size()]));
writeBody(writer, persons);
} finally {
if (writer != null)
writer.close();
}
return values;
}
Aggregations