public class CSVWriter extends AbstractTableWriter
TableWriter for CSV files.| Constructor and Description |
|---|
CSVWriter(Writer w,
TableLayout l)
Construct a new CSV writer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
No-op close implementaiton.
|
TableLayout |
getLayout()
Get the layout of this table.
|
static CSVWriter |
open(File file,
TableLayout layout)
Open a CSV writer to write to an auto-compressed file.
|
static CSVWriter |
open(File file,
TableLayout layout,
CompressionMode compression)
Open a CSV writer to write to a file.
|
void |
writeRow(List<?> row)
Write a row to the table.
|
checkRowWidth, writeRowpublic CSVWriter(@Nonnull Writer w, @Nullable TableLayout l) throws IOException
w - The underlying writer to output to.l - The table layout, or null if the table has no headers.IOException - if there is an error writing the column headers.public void close()
throws IOException
AbstractTableWriterclose in interface Closeableclose in interface AutoCloseableclose in interface TableWriterclose in class AbstractTableWriterIOExceptionpublic void writeRow(List<?> row) throws IOException
TableWriterrow - A row of values. If the table requires more columns, the remaining columns are
empty. The row is copied if necessary; the caller is free to re-use the same array
for returnValue calls.IOException - if an error occurs writing the row.public TableLayout getLayout()
TableWriterpublic static CSVWriter open(File file, TableLayout layout, CompressionMode compression) throws IOException
file - The file to write to.layout - The layout of the table.compression - What compression, if any, to use.file.IOException - if there is an error opening the file or writing the column header.public static CSVWriter open(File file, @Nullable TableLayout layout) throws IOException
file - The file.layout - The table layout.IOException - if there is an error opening the file or writing the column header.open(File, TableLayout, CompressionMode)