Top Description Fields Constructors Methods
com.univocity.parsers.tsv

public Class TsvWriter

extends AbstractWriter<TsvWriterSettings>
Class Inheritance
Imports
com.univocity.parsers.common.*, java.io.*, java.nio.charset.*

A powerful and flexible TSV writer implementation.
Author
Univocity Software Pty Ltd - [email protected]
See Also
TsvFormat, TsvWriterSettings, TsvParser, AbstractWriter

Field Summary

Modifier and TypeField and Description
private char
private char
private boolean
private char
Inherited from com.univocity.parsers.common.AbstractWriter:
appendercommentemptyValueexpandRowsheadersheaderTrimFlagsignoreLeadingignoreTrailingnullValuerecordCountusingNullOrEmptyValuewhitespaceRangeStartwritingHeaders

Constructor Summary

AccessConstructor and Description
public
TsvWriter(TsvWriterSettings
the TSV writer configuration
settings
)

The TsvWriter supports all settings provided by TsvWriterSettings, and requires this configuration to be properly initialized.

public
TsvWriter(Writer
the output resource that will receive TSV records produced by this class.
writer
,
TsvWriterSettings
the TSV writer configuration
settings
)

The TsvWriter supports all settings provided by TsvWriterSettings, and requires this configuration to be properly initialized.

public
TsvWriter(File
the output file that will receive TSV records produced by this class.
file
,
TsvWriterSettings
the TSV writer configuration
settings
)

The TsvWriter supports all settings provided by TsvWriterSettings, and requires this configuration to be properly initialized.

public
TsvWriter(File
the output file that will receive TSV records produced by this class.
file
,
String
the encoding of the file
encoding
,
TsvWriterSettings
the TSV writer configuration
settings
)

The TsvWriter supports all settings provided by TsvWriterSettings, and requires this configuration to be properly initialized.

public
TsvWriter(File
the output file that will receive TSV records produced by this class.
file
,
Charset
the encoding of the file
encoding
,
TsvWriterSettings
the TSV writer configuration
settings
)

The TsvWriter supports all settings provided by TsvWriterSettings, and requires this configuration to be properly initialized.

public
TsvWriter(OutputStream
the output stream that will be written with the TSV records produced by this class.
output
,
TsvWriterSettings
the TSV writer configuration
settings
)

The TsvWriter supports all settings provided by TsvWriterSettings, and requires this configuration to be properly initialized.

public
TsvWriter(OutputStream
the output stream that will be written with the TSV records produced by this class.
output
,
String
the encoding of the stream
encoding
,
TsvWriterSettings
the TSV writer configuration
settings
)

The TsvWriter supports all settings provided by TsvWriterSettings, and requires this configuration to be properly initialized.

public
TsvWriter(OutputStream
the output stream that will be written with the TSV records produced by this class.
output
,
Charset
the encoding of the stream
encoding
,
TsvWriterSettings
the TSV writer configuration
settings
)

The TsvWriter supports all settings provided by TsvWriterSettings, and requires this configuration to be properly initialized.

Method Summary

Modifier and TypeMethod and Description
private void
append(String element, boolean allowTrim)

protected final void
initialize(TsvWriterSettings
the TSV writer configuration
settings
)

Implements abstract com.univocity.parsers.common.AbstractWriter.initialize.

Initializes the TSV writer with TSV-specific configuration
protected void
processRow(Object[]
the data to be written to the output in the expected format.
row
)

Implements abstract com.univocity.parsers.common.AbstractWriter.processRow.

Format-specific implementation for writing a single record into the output.
Inherited from com.univocity.parsers.common.AbstractWriter:
addStringValuesaddValueaddValueaddValueaddValuesaddValuesallowTrimappendToRowappendToRowappendValueToRowclosecommentRowcommentRowToStringdiscardValuesenableNewlineAfterRecordexpandflushgetRecordCountgetStringValueprocessObjectRecordsprocessObjectRecordsAndCloseprocessObjectRecordsAndCloseprocessObjectRecordsToStringprocessObjectRecordsToStringprocessRecordprocessRecordprocessRecordprocessRecordprocessRecordprocessRecordsprocessRecordsprocessRecordsprocessRecordsprocessRecordsprocessRecordsAndCloseprocessRecordsAndCloseprocessRecordsAndCloseprocessRecordsAndCloseprocessRecordsToStringprocessRecordsToStringprocessRecordsToStringprocessRecordsToStringprocessRecordToStringprocessRecordToStringprocessRecordToStringprocessRecordToStringprocessRecordToStringprocessValuesToRowprocessValuesToStringskipLeadingWhitespaceupdateFieldExclusionupdateFieldExclusionupdateFieldSelectionupdateFieldSelectionwriteEmptyRowwriteHeaderswriteHeaderswriteHeaderswriteHeadersToStringwriteHeadersToStringwriteHeadersToStringwriteObjectRowswriteObjectRowsAndClosewriteObjectRowsAndClosewriteObjectRowsToStringwriteRecordwriteRecordswriteRecordswriteRecordsAndClosewriteRecordsAndClosewriteRecordsAndClosewriteRecordsToStringwriteRecordsToStringwriteRecordToStringwriteRowwriteRowwriteRowwriteRowwriteRowwriteRowwriteRowswriteRowswriteRowswriteRowswriteRowswriteRowsAndClosewriteRowsAndClosewriteRowsAndClosewriteRowsAndClosewriteRowsAndClosewriteRowsToStringwriteRowsToStringwriteRowsToStringwriteRowsToStringwriteRowsToStringwriteRowToStringwriteRowToStringwriteRowToStringwriteRowToStringwriteRowToStringwriteStringRowswriteStringRowswriteStringRowswriteStringRowsAndClosewriteStringRowsAndClosewriteStringRowsAndClosewriteStringRowsToStringwriteStringRowsToStringwriteStringRowsToStringwriteValuesToRowwriteValuesToString

Field Detail

escapeCharback to summary
private char escapeChar
escapedTabCharback to summary
private char escapedTabChar
joinLinesback to summary
private boolean joinLines
newLineback to summary
private char newLine

Constructor Detail

TsvWriterback to summary
public TsvWriter(TsvWriterSettings settings)

The TsvWriter supports all settings provided by TsvWriterSettings, and requires this configuration to be properly initialized.

Important Note

by not providing an instance of java.io.Writer to this constructor, only the operations that write to Strings are available.

Parameters
settings:TsvWriterSettings

the TSV writer configuration

TsvWriterback to summary
public TsvWriter(Writer writer, TsvWriterSettings settings)

The TsvWriter supports all settings provided by TsvWriterSettings, and requires this configuration to be properly initialized.

Parameters
writer:Writer

the output resource that will receive TSV records produced by this class.

settings:TsvWriterSettings

the TSV writer configuration

TsvWriterback to summary
public TsvWriter(File file, TsvWriterSettings settings)

The TsvWriter supports all settings provided by TsvWriterSettings, and requires this configuration to be properly initialized.

Parameters
file:File

the output file that will receive TSV records produced by this class.

settings:TsvWriterSettings

the TSV writer configuration

TsvWriterback to summary
public TsvWriter(File file, String encoding, TsvWriterSettings settings)

The TsvWriter supports all settings provided by TsvWriterSettings, and requires this configuration to be properly initialized.

Parameters
file:File

the output file that will receive TSV records produced by this class.

encoding:String

the encoding of the file

settings:TsvWriterSettings

the TSV writer configuration

TsvWriterback to summary
public TsvWriter(File file, Charset encoding, TsvWriterSettings settings)

The TsvWriter supports all settings provided by TsvWriterSettings, and requires this configuration to be properly initialized.

Parameters
file:File

the output file that will receive TSV records produced by this class.

encoding:Charset

the encoding of the file

settings:TsvWriterSettings

the TSV writer configuration

TsvWriterback to summary
public TsvWriter(OutputStream output, TsvWriterSettings settings)

The TsvWriter supports all settings provided by TsvWriterSettings, and requires this configuration to be properly initialized.

Parameters
output:OutputStream

the output stream that will be written with the TSV records produced by this class.

settings:TsvWriterSettings

the TSV writer configuration

TsvWriterback to summary
public TsvWriter(OutputStream output, String encoding, TsvWriterSettings settings)

The TsvWriter supports all settings provided by TsvWriterSettings, and requires this configuration to be properly initialized.

Parameters
output:OutputStream

the output stream that will be written with the TSV records produced by this class.

encoding:String

the encoding of the stream

settings:TsvWriterSettings

the TSV writer configuration

TsvWriterback to summary
public TsvWriter(OutputStream output, Charset encoding, TsvWriterSettings settings)

The TsvWriter supports all settings provided by TsvWriterSettings, and requires this configuration to be properly initialized.

Parameters
output:OutputStream

the output stream that will be written with the TSV records produced by this class.

encoding:Charset

the encoding of the stream

settings:TsvWriterSettings

the TSV writer configuration

Method Detail

appendback to summary
private void append(String element, boolean allowTrim)
initializeback to summary
protected final void initialize(TsvWriterSettings settings)

Implements abstract com.univocity.parsers.common.AbstractWriter.initialize.

Initializes the TSV writer with TSV-specific configuration

Parameters
settings:TsvWriterSettings

the TSV writer configuration

processRowback to summary
protected void processRow(Object[] row)

Implements abstract com.univocity.parsers.common.AbstractWriter.processRow.

Doc from com.univocity.parsers.common.AbstractWriter.processRow.

Format-specific implementation for writing a single record into the output. 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 processRow(Object[]). In general, an implementation of AbstractWriter#processRow(Object[]) will perform the following steps:

Once the 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 com.univocity.parsers.fixed.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.
Parameters
row:Object[]

the data to be written to the output in the expected format.

Annotations
@Override