public final class CsvWriter
extends java.lang.Object
implements java.io.Closeable
Example use:
try (CsvWriter csv = CsvWriter.builder().build(path)) {
csv.writeRow("Hello", "world");
}
| Modifier and Type | Class and Description |
|---|---|
static class |
CsvWriter.CsvWriterBuilder
This builder is used to create configured instances of
CsvWriter. |
| Modifier and Type | Method and Description |
|---|---|
static CsvWriter.CsvWriterBuilder |
builder()
Creates a
CsvWriter.CsvWriterBuilder instance used to configure and create instances of
this class. |
void |
close() |
java.lang.String |
toString() |
CsvWriter |
writeComment(java.lang.String comment)
Writes a comment line and new line character(s) at the end.
|
CsvWriter |
writeRow(java.lang.Iterable<java.lang.String> values)
Writes a complete line - one or more fields and new line character(s) at the end.
|
CsvWriter |
writeRow(java.lang.String... values)
Writes a complete line - one or more fields and new line character(s) at the end.
|
public static CsvWriter.CsvWriterBuilder builder()
CsvWriter.CsvWriterBuilder instance used to configure and create instances of
this class.public CsvWriter writeRow(java.lang.Iterable<java.lang.String> values)
values - the fields to write (null values are handled as empty strings, if
not configured otherwise (QuoteStrategy.EMPTY)).java.io.UncheckedIOException - if a write error occurswriteRow(String...)public CsvWriter writeRow(java.lang.String... values)
values - the fields to write (null values are handled as empty strings, if
not configured otherwise (QuoteStrategy.EMPTY))java.io.UncheckedIOException - if a write error occurswriteRow(Iterable)public CsvWriter writeComment(java.lang.String comment)
comment - the comment to write. The comment character
(configured by CsvWriter.CsvWriterBuilder.commentCharacter(char)) is automatically prepended.
Empty or null values results in a line only consisting of the comment character.
If the argument comment contains line break characters (CR, LF), multiple comment lines
will be written, terminated with the line break character configured by
CsvWriter.CsvWriterBuilder.lineDelimiter(LineDelimiter).java.io.UncheckedIOException - if a write error occurspublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Object