|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.univocity.parsers.common.AbstractWriter<CsvWriterSettings>
com.univocity.parsers.csv.CsvWriter
public class CsvWriter
A powerful and flexible CSV writer implementation.
CsvFormat,
CsvWriterSettings,
CsvParser,
AbstractWriter| Field Summary |
|---|
| Fields inherited from class com.univocity.parsers.common.AbstractWriter |
|---|
appender, emptyValue, expandRows, nullValue, usingNullOrEmptyValue, whitespaceRangeStart, writingHeaders |
| Constructor Summary | |
|---|---|
CsvWriter(CsvWriterSettings settings)
The CsvWriter supports all settings provided by CsvWriterSettings, and requires this configuration to be properly initialized. |
|
CsvWriter(File file,
Charset encoding,
CsvWriterSettings settings)
The CsvWriter supports all settings provided by CsvWriterSettings, and requires this configuration to be properly initialized. |
|
CsvWriter(File file,
CsvWriterSettings settings)
The CsvWriter supports all settings provided by CsvWriterSettings, and requires this configuration to be properly initialized. |
|
CsvWriter(File file,
String encoding,
CsvWriterSettings settings)
The CsvWriter supports all settings provided by CsvWriterSettings, and requires this configuration to be properly initialized. |
|
CsvWriter(OutputStream output,
Charset encoding,
CsvWriterSettings settings)
The CsvWriter supports all settings provided by CsvWriterSettings, and requires this configuration to be properly initialized. |
|
CsvWriter(OutputStream output,
CsvWriterSettings settings)
The CsvWriter supports all settings provided by CsvWriterSettings, and requires this configuration to be properly initialized. |
|
CsvWriter(OutputStream output,
String encoding,
CsvWriterSettings settings)
The CsvWriter supports all settings provided by CsvWriterSettings, and requires this configuration to be properly initialized. |
|
CsvWriter(Writer writer,
CsvWriterSettings settings)
The CsvWriter supports all settings provided by CsvWriterSettings, and requires this configuration to be properly initialized. |
|
| Method Summary | |
|---|---|
protected void |
initialize(CsvWriterSettings settings)
Initializes the CSV writer with CSV-specific configuration |
protected void |
processRow(Object[] row)
Format-specific implementation for writing a single record into the output. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CsvWriter(CsvWriterSettings settings)
CsvWriterSettings, and requires this configuration to be properly initialized.
Important: by not providing an instance of Writer to this constructor, only the operations that write to Strings are available.
settings - the CSV writer configuration
public CsvWriter(Writer writer,
CsvWriterSettings settings)
CsvWriterSettings, and requires this configuration to be properly initialized.
writer - the output resource that will receive CSV records produced by this class.settings - the CSV writer configuration
public CsvWriter(File file,
CsvWriterSettings settings)
CsvWriterSettings, and requires this configuration to be properly initialized.
file - the output file that will receive CSV records produced by this class.settings - the CSV writer configuration
public CsvWriter(File file,
String encoding,
CsvWriterSettings settings)
CsvWriterSettings, and requires this configuration to be properly initialized.
file - the output file that will receive CSV records produced by this class.encoding - the encoding of the filesettings - the CSV writer configuration
public CsvWriter(File file,
Charset encoding,
CsvWriterSettings settings)
CsvWriterSettings, and requires this configuration to be properly initialized.
file - the output file that will receive CSV records produced by this class.encoding - the encoding of the filesettings - the CSV writer configuration
public CsvWriter(OutputStream output,
CsvWriterSettings settings)
CsvWriterSettings, and requires this configuration to be properly initialized.
output - the output stream that will be written with the CSV records produced by this class.settings - the CSV writer configuration
public CsvWriter(OutputStream output,
String encoding,
CsvWriterSettings settings)
CsvWriterSettings, and requires this configuration to be properly initialized.
output - the output stream that will be written with the CSV records produced by this class.encoding - the encoding of the streamsettings - the CSV writer configuration
public CsvWriter(OutputStream output,
Charset encoding,
CsvWriterSettings settings)
CsvWriterSettings, and requires this configuration to be properly initialized.
output - the output stream that will be written with the CSV records produced by this class.encoding - the encoding of the streamsettings - the CSV writer configuration| Method Detail |
|---|
protected final void initialize(CsvWriterSettings settings)
initialize in class AbstractWriter<CsvWriterSettings>settings - the CSV writer configurationprotected void processRow(Object[] row)
AbstractWriter The AbstractWriter handles the initialization and processing of the output until it is ready to be written (generally, reorganizing it and passing it on to a RowWriterProcessor).
It then delegates the record to the writer-specific implementation defined by AbstractWriter.processRow(Object[]). In general, an implementation of AbstractWriter.processRow(Object[]) will perform the following steps:
AbstractWriter.appender object. The an individual value is processed, the AbstractWriter.appendValueToRow() method must be called.
This will clear the accumulated value in AbstractWriter.appender and add it to the output row.AbstractWriter.appendToRow(char) Once the AbstractWriter.processRow(Object[]) method returns, a row will be written to the output with the processed information, and a newline will be automatically written after the given contents, unless this is a
FixedWidthWriter whose FixedWidthWriterSettings.getWriteLineSeparatorAfterRecord() evaluates to false. The newline character sequence will conform to what is specified in Format.getLineSeparator()
This cycle repeats until the writing process is stopped by the user or an error happens.
In case of errors, the unchecked exception TextWritingException will be thrown and all resources in use will be closed automatically. The exception should contain the cause and more information about the output state when the error happened.
processRow in class AbstractWriter<CsvWriterSettings>row - the data to be written to the output in the expected format.CharAppender,
CommonWriterSettings
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||