public class CsvWriter extends CsvBase
columnSeparator, DEFAULT_COLUMN_SEPARATOR, DEFAULT_FIELD_DELIMITER, DEFAULT_ROW_SEPARATOR, fieldDelimiter, lockObject, rowSeparator
Constructor and Description |
---|
CsvWriter(@Nullable StringWriter stringWriter)
Initializes a new instance of the CsvWriter class.
|
CsvWriter(@Nullable StringWriter stringWriter,
@Nullable Character columnSeparator,
@Nullable String rowSeparator,
@Nullable String fieldDelimiter,
@Nullable Integer writeChunkSize,
@Nullable QuotingBehavior quotingBehavior)
Initializes a new instance of the CsvWriter class.
|
CsvWriter(@Nullable StringWriter stringWriter,
char columnSeparator,
String rowSeparator,
String fieldDelimiter)
Initializes a new instance of the CsvWriter class.
|
CsvWriter(@Nullable StringWriter stringWriter,
char columnSeparator,
String rowSeparator,
String fieldDelimiter,
int writeChunkSize)
Initializes a new instance of the CsvWriter class.
|
CsvWriter(StringWriter stringWriter,
char columnSeparator,
String rowSeparator,
String fieldDelimiter,
QuotingBehavior quotingBehavior)
Initializes a new instance of the CsvWriter class.
|
CsvWriter(StringWriter stringWriter,
QuotingBehavior quotingBehavior)
Initializes a new instance of the CsvWriter class.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected void |
finalize() |
CsvWriter |
flush()
Flushes all internal buffers to the underlying writer.
|
CsvWriter |
flushUnderlyingWriter()
Calls flush on the underlying stringWriter.
|
CsvWriter |
write()
Writes an empty string (followed by a column-separator).
|
CsvWriter |
write(@Nullable List<String> csvData)
Writes a row to the CSV not ending with a rowSeparator.
|
CsvWriter |
write(@Nullable String csvData)
Writes a field to the CSV and appends a columnSeparator in front of the new entry if necessary.
|
CsvWriter |
writeAll(@Nullable List<List<String>> csvData)
Writes all rows to a CSV.
|
CsvWriter |
writeLine()
Writes a row-separator, advancing the writer to a new row.
|
CsvWriter |
writeLine(@Nullable List<String> csvData)
Writes a row to the CSV ending with a rowSeparator.
|
CsvWriter |
writeLine(@Nullable String csvData)
Writes a field to the CSV and appends a columnSeparator in front of the new entry if necessary.
|
public CsvWriter(@Nullable @Nullable StringWriter stringWriter)
stringWriter
- The StringWriter you want the CsvWriter to attach to.public CsvWriter(StringWriter stringWriter, QuotingBehavior quotingBehavior)
stringWriter
- The StringWriter you want the CsvWriter to attach to.quotingBehavior
- The quotingBehavior tells the writer how to quote fields in the resulting CSV. Minimal only lets him apply quotes where absolutely
necessary. All means that he always applies them, necessary or not.public CsvWriter(@Nullable @Nullable StringWriter stringWriter, char columnSeparator, String rowSeparator, String fieldDelimiter)
stringWriter
- The StringWriter you want the CsvWriter to attach to.columnSeparator
- A delimiter to separate columns (e.g. ';').rowSeparator
- A delimiter to separate rows (e.g. System.getProperty("line.separator")).fieldDelimiter
- A delimiter to enclose special-character-containing strings (e.g. " or just the empty string).public CsvWriter(StringWriter stringWriter, char columnSeparator, String rowSeparator, String fieldDelimiter, QuotingBehavior quotingBehavior)
stringWriter
- The StringWriter you want the CsvWriter to attach to.columnSeparator
- A delimiter to separate columns (e.g. ';').rowSeparator
- A delimiter to separate rows (e.g. System.getProperty("line.separator")).fieldDelimiter
- A delimiter to enclose special-character-containing strings (e.g. " or just the empty string).quotingBehavior
- The quotingBehavior tells the writer how to quote fields in the resulting CSV. Minimal only lets him apply quotes where absolutely
necessary. All means that he always applies them, necessary or not.public CsvWriter(@Nullable @Nullable StringWriter stringWriter, char columnSeparator, String rowSeparator, String fieldDelimiter, int writeChunkSize)
stringWriter
- The StringWriter you want the CsvWriter to attach to.columnSeparator
- A delimiter to separate columns (e.g. ';').rowSeparator
- A delimiter to separate rows (e.g. System.getProperty("line.separator")).fieldDelimiter
- A delimiter to enclose special-character-containing strings (e.g. " or just the empty string).writeChunkSize
- Size of one chunk (the minimal value is rowSeparator.length() and is automatically assigned if the given value was too small). The
bufferSize is automatically allocated in any case. It will be readChunkSize + rowSeparator.length() due to the parsing technique used).public CsvWriter(@Nullable @Nullable StringWriter stringWriter, @Nullable @Nullable Character columnSeparator, @Nullable @Nullable String rowSeparator, @Nullable @Nullable String fieldDelimiter, @Nullable @Nullable Integer writeChunkSize, @Nullable @Nullable QuotingBehavior quotingBehavior)
stringWriter
- The StringWriter you want the CsvWriter to attach to.columnSeparator
- A delimiter to separate columns (e.g. ';').rowSeparator
- A delimiter to separate rows (e.g. System.getProperty("line.separator")).fieldDelimiter
- A delimiter to enclose special-character-containing strings (e.g. " or just the empty string).writeChunkSize
- Size of one chunk (the minimal value is rowSeparator.length() and is automatically assigned if the given value was too small). The
bufferSize is automatically allocated in any case. It will be readChunkSize + rowSeparator.length() due to the parsing technique used).quotingBehavior
- The quotingBehavior tells the writer how to quote fields in the resulting CSV. Minimal only lets him apply quotes where absolutely
necessary. All means that he always applies them, necessary or not.public CsvWriter flush() throws IOException
IOException
- If the underlying stream could not be accessed.public CsvWriter flushUnderlyingWriter() throws IOException
IOException
- If the underlying stream could not be accessed.public CsvWriter write() throws IOException
IOException
- If the underlying stream could not be accessed.public CsvWriter writeLine() throws IOException
IOException
- If the underlying stream could not be accessed.public CsvWriter writeLine(@Nullable @Nullable String csvData) throws IOException
csvData
- The data that should be written.IOException
- If the underlying stream could not be accessed.public CsvWriter write(@Nullable @Nullable String csvData) throws IOException
csvData
- The data, that should be written to the CSV.IOException
- If the underlying stream could not be accessed.public CsvWriter writeLine(@Nullable @Nullable List<String> csvData) throws IOException
csvData
- The data, that should be written to the CSV.IOException
- If the underlying stream could not be accessed.public CsvWriter write(@Nullable @Nullable List<String> csvData) throws IOException
csvData
- The data, that should be written to the CSV.IOException
- If the underlying stream could not be accessed.public CsvWriter writeAll(@Nullable @Nullable List<List<String>> csvData) throws IOException
csvData
- The data, that should be written to the CSV.IOException
- If the underlying stream could not be accessed.public void close() throws IOException
IOException
Copyright © 2016 Unterrainer Informatik OG. All rights reserved.