Package org.supercsv.io
Class CsvListWriter
- java.lang.Object
-
- org.supercsv.io.AbstractCsvWriter
-
- org.supercsv.io.CsvListWriter
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
,ICsvListWriter
,ICsvWriter
public class CsvListWriter extends AbstractCsvWriter implements ICsvListWriter
CsvListWriter is a simple writer capable of writing arrays and Lists to a CSV file.- Author:
- Kasper B. Graversen, James Bassett
-
-
Constructor Summary
Constructors Constructor Description CsvListWriter(java.io.Writer writer, CsvPreference preference)
Constructs a new CsvListWriter with the supplied Writer and CSV preferences.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
write(java.lang.Object... columns)
Writes a array of Objects as columns of a CSV file.void
write(java.lang.String... columns)
Writes an array of strings as columns of a CSV file.void
write(java.util.List<?> columns)
Writes a List of Objects as columns of a CSV file.void
write(java.util.List<?> columns, CellProcessor[] processors)
Writes a List of Objects as columns of a CSV file, performing any necessary processing beforehand.-
Methods inherited from class org.supercsv.io.AbstractCsvWriter
close, flush, getLineNumber, getRowNumber, incrementRowAndLineNo, writeComment, writeHeader, writeRow, writeRow, writeRow
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.supercsv.io.ICsvWriter
getLineNumber, getRowNumber, writeComment, writeHeader
-
-
-
-
Constructor Detail
-
CsvListWriter
public CsvListWriter(java.io.Writer writer, CsvPreference preference)
Constructs a new CsvListWriter with the supplied Writer and CSV preferences. Note that the reader will be wrapped in a BufferedReader before accessed.- Parameters:
writer
- the writerpreference
- the CSV preferences- Throws:
java.lang.NullPointerException
- if writer or preference are null
-
-
Method Detail
-
write
public void write(java.util.List<?> columns, CellProcessor[] processors) throws java.io.IOException
Writes a List of Objects as columns of a CSV file, performing any necessary processing beforehand. toString() will be called on each (processed) element prior to writing.- Specified by:
write
in interfaceICsvListWriter
- Parameters:
columns
- the columns to writeprocessors
- an array of CellProcessors used to further process data before it is written (each element in the processors array corresponds with a CSV column - the number of processors should match the number of columns). A null entry indicates no further processing is required (the value returned by toString() will be written as the column value).- Throws:
java.io.IOException
- If an I/O error occurs
-
write
public void write(java.util.List<?> columns) throws java.io.IOException
Writes a List of Objects as columns of a CSV file. toString() will be called on each element prior to writing.- Specified by:
write
in interfaceICsvListWriter
- Parameters:
columns
- the columns to write- Throws:
java.io.IOException
- If an I/O error occurs
-
write
public void write(java.lang.Object... columns) throws java.io.IOException
Writes a array of Objects as columns of a CSV file. toString() will be called on each element prior to writing.- Specified by:
write
in interfaceICsvListWriter
- Parameters:
columns
- the columns to write- Throws:
java.io.IOException
- If an I/O error occurs
-
write
public void write(java.lang.String... columns) throws java.io.IOException
Writes an array of strings as columns of a CSV file.- Specified by:
write
in interfaceICsvListWriter
- Parameters:
columns
- the columns to write- Throws:
java.io.IOException
- If an I/O error occurs
-
-