public abstract class AbstractCsvWriter extends java.lang.Object implements ICsvWriter
Constructor and Description |
---|
AbstractCsvWriter(java.io.Writer writer,
CsvPreference preference)
Constructs a new AbstractCsvWriter with the supplied writer and preferences.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underlying writer, flushing it first.
|
protected java.lang.String |
escapeString(java.lang.String csvElement)
Deprecated.
this method will be removed in the next major release, in favour of supplying your own CsvEncoder via
the CsvPreference object. If you have overridden this method, it will not delegate to the CsvEncoder
at all.
|
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(java.lang.String comment)
Writes a single-line comment to the CSV file (the comment must already include any special comment characters
e.g.
|
void |
writeHeader(java.lang.String... header)
Writes the header of the CSV file.
|
protected void |
writeRow(java.util.List<?> columns)
Writes a List of columns as a line to the CsvWriter.
|
protected void |
writeRow(java.lang.Object... columns)
Writes one or more Object columns as a line to the CsvWriter.
|
protected void |
writeRow(java.lang.String... columns)
Writes one or more String columns as a line to the CsvWriter.
|
public AbstractCsvWriter(java.io.Writer writer, CsvPreference preference)
writer
- the stream to write topreference
- the CSV preferencesjava.lang.NullPointerException
- if writer or preference are nullpublic void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
java.io.IOException
protected java.lang.String escapeString(java.lang.String csvElement)
csvElement
- an element of a CSV fileprotected void incrementRowAndLineNo()
getLineNumber()
and getRowNumber()
can be called after writing to return the line/row just
written.public int getLineNumber()
getLineNumber
in interface ICsvWriter
public int getRowNumber()
getRowNumber
in interface ICsvWriter
protected void writeRow(java.util.List<?> columns) throws java.io.IOException
columns
- the columns to writejava.lang.IllegalArgumentException
- if columns.size == 0java.io.IOException
- If an I/O error occursjava.lang.NullPointerException
- if columns is nullprotected void writeRow(java.lang.Object... columns) throws java.io.IOException
columns
- the columns to writejava.lang.IllegalArgumentException
- if columns.length == 0java.io.IOException
- If an I/O error occursjava.lang.NullPointerException
- if columns is nullprotected void writeRow(java.lang.String... columns) throws java.io.IOException
columns
- the columns to writejava.lang.IllegalArgumentException
- if columns.length == 0java.io.IOException
- If an I/O error occursjava.lang.NullPointerException
- if columns is nullpublic void writeComment(java.lang.String comment) throws java.io.IOException
writeComment
in interface ICsvWriter
comment
- the commentjava.io.IOException
- if an I/O error occurspublic void writeHeader(java.lang.String... header) throws java.io.IOException
writeHeader
in interface ICsvWriter
header
- one or more header Stringsjava.io.IOException
- if an I/O error occursCopyright © 2007-2014 Super CSV. All Rights Reserved.