public class CSVWriter extends AbstractTableWriter
TableWriter for CSV files.| Constructor and Description |
|---|
CSVWriter(java.io.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(java.io.File file,
TableLayout layout)
Open a CSV writer to write to an auto-compressed file.
|
static CSVWriter |
open(java.io.File file,
TableLayout layout,
CompressionMode compression)
Open a CSV writer to write to a file.
|
void |
writeRow(java.util.List<?> row)
Write a row to the table.
|
checkRowWidth, writeRowpublic CSVWriter(@Nonnull
java.io.Writer w,
@Nullable
TableLayout l)
throws java.io.IOException
w - The underlying writer to output to.l - The table layout, or null if the table has no headers.java.io.IOException - if there is an error writing the column headers.public void close()
throws java.io.IOException
AbstractTableWriterclose in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface TableWriterclose in class AbstractTableWriterjava.io.IOExceptionpublic void writeRow(java.util.List<?> row)
throws java.io.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.java.io.IOException - if an error occurs writing the row.public TableLayout getLayout()
TableWriterpublic static CSVWriter open(java.io.File file, TableLayout layout, CompressionMode compression) throws java.io.IOException
file - The file to write to.layout - The layout of the table.compression - What compression, if any, to use.file.java.io.IOException - if there is an error opening the file or writing the column header.public static CSVWriter open(java.io.File file, @Nullable TableLayout layout) throws java.io.IOException
file - The file.layout - The table layout.java.io.IOException - if there is an error opening the file or writing the column header.open(File, TableLayout, CompressionMode)