public abstract class AbstractCsvWriter extends Object implements ICsvWriter
| Constructor and Description |
|---|
AbstractCsvWriter(Writer writer,
CsvPreference preference)
Constructs a new AbstractCsvWriter with the supplied writer and preferences.
|
AbstractCsvWriter(Writer writer,
CsvPreference preference,
boolean bufferizeWriter)
Constructs a new AbstractCsvWriter with the supplied writer, preferences and option
to wrap the writer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the underlying writer, flushing it first.
|
void |
flush()
Flushes the underlying writer.
|
int |
getLineNumber()
Gets the current position in the file.
|
int |
getRowNumber()
Gets the current row number (i.e.
|
protected void |
incrementRowAndLineNo()
In order to maintain the current row and line numbers, this method must be called at the very
beginning of every write method implemented in concrete CSV writers.
|
void |
writeComment(String comment)
Writes a single-line comment to the CSV file (the comment must already include any special comment characters
e.g.
|
void |
writeHeader(String... header)
Writes the header of the CSV file.
|
protected void |
writeRow(List<?> columns)
Writes a List of columns as a line to the CsvWriter.
|
protected void |
writeRow(Object... columns)
Writes one or more Object columns as a line to the CsvWriter.
|
protected void |
writeRow(String... columns)
Writes one or more String columns as a line to the CsvWriter.
|
public AbstractCsvWriter(Writer writer, CsvPreference preference)
writer - the stream to write topreference - the CSV preferencesNullPointerException - if writer or preference are nullpublic AbstractCsvWriter(Writer writer, CsvPreference preference, boolean bufferizeWriter)
writer - the stream to write topreference - the CSV preferencesbufferizeWriter - indicates if the writer should be wrapped internally with a BufferedWriterNullPointerException - if writer or preference are nullpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic void flush()
throws IOException
flush in interface FlushableIOExceptionprotected void incrementRowAndLineNo()
getLineNumber() and getRowNumber() can be called after writing to return the line/row just
written.public int getLineNumber()
getLineNumber in interface ICsvWriterpublic int getRowNumber()
getRowNumber in interface ICsvWriterprotected void writeRow(List<?> columns) throws IOException
columns - the columns to writeIllegalArgumentException - if columns.size == 0IOException - If an I/O error occursNullPointerException - if columns is nullprotected void writeRow(Object... columns) throws IOException
columns - the columns to writeIllegalArgumentException - if columns.length == 0IOException - If an I/O error occursNullPointerException - if columns is nullprotected void writeRow(String... columns) throws IOException
columns - the columns to writeIllegalArgumentException - if columns.length == 0IOException - If an I/O error occursNullPointerException - if columns is nullpublic void writeComment(String comment) throws IOException
writeComment in interface ICsvWritercomment - the commentIOException - if an I/O error occurspublic void writeHeader(String... header) throws IOException
writeHeader in interface ICsvWriterheader - one or more header StringsIOException - if an I/O error occursCopyright © 2007–2015 Super CSV. All rights reserved.