public class CSVWriter extends Object implements AutoCloseable
Modifier and Type | Method and Description |
---|---|
void |
close() |
static CSVWriter |
create(Path path)
Creates and starts a CSVWriter (it's always allowed, so will never return null)
|
static Optional<CSVWriter> |
createFromOutputter(String outputName,
OutputterChecked outputter)
Creates and starts a CSVWriter if it's allowed, otherwise returns
Optional.empty() . |
static Optional<CSVWriter> |
createFromOutputterWithHeaders(String outputName,
OutputterChecked outputter,
java.util.function.Supplier<List<String>> headerNames,
ErrorReporter errorReporter)
Like
createFromOutputter(String, OutputterChecked) but suppresses any exceptions
into an error log - and writes headers. |
boolean |
hasWrittenHeaders() |
boolean |
isOutputEnabled() |
void |
writeHeaders(List<String> headerNames) |
void |
writeRow(List<TypedValue> elements) |
public static Optional<CSVWriter> createFromOutputterWithHeaders(String outputName, OutputterChecked outputter, java.util.function.Supplier<List<String>> headerNames, ErrorReporter errorReporter)
createFromOutputter(String, OutputterChecked)
but suppresses any exceptions
into an error log - and writes headers.outputName
- output-nameoutputter
- output-managerheaderNames
- header-names for the CSV fileerrorReporter
- used to reporter an error if the output cannot be created.public static Optional<CSVWriter> createFromOutputter(String outputName, OutputterChecked outputter) throws OutputWriteFailedException
Optional.empty()
.outputName
- output-nameoutputter
- output-managerOutputWriteFailedException
- if the CSV file cannot be created successfully.public static CSVWriter create(Path path) throws OutputWriteFailedException
path
- path to write the CSV toOutputWriteFailedException
public boolean hasWrittenHeaders()
public boolean isOutputEnabled()
public void writeRow(List<TypedValue> elements)
public void close()
close
in interface AutoCloseable
Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.