public final class CsvWriter
extends java.lang.Object
| Constructor and Description |
|---|
CsvWriter() |
| Modifier and Type | Method and Description |
|---|---|
CsvAppender |
append(java.io.File file,
java.nio.charset.Charset charset)
Constructs a
CsvAppender for the specified File. |
CsvAppender |
append(java.nio.file.Path path,
java.nio.charset.Charset charset)
Constructs a
CsvAppender for the specified Path. |
CsvAppender |
append(java.io.Writer writer)
Constructs a
CsvAppender for the specified Writer. |
void |
setAlwaysDelimitText(boolean alwaysDelimitText)
Sets if fields should always delimited using the
textDelimiter (default: false). |
void |
setFieldSeparator(char fieldSeparator)
Sets the field separator character (default: ',' - comma).
|
void |
setLineDelimiter(char[] lineDelimiter)
Sets the line delimiter character(s) to be used (default:
System.lineSeparator()). |
void |
setTextDelimiter(char textDelimiter)
Sets the text delimiter character (default: '"' - double quotes).
|
void |
write(java.io.File file,
java.nio.charset.Charset charset,
java.util.Collection<java.lang.String[]> data)
Writes all specified data to the file.
|
void |
write(java.nio.file.Path path,
java.nio.charset.Charset charset,
java.util.Collection<java.lang.String[]> data)
Writes all specified data to the path.
|
void |
write(java.io.Writer writer,
java.util.Collection<java.lang.String[]> data)
Writes all specified data to the writer.
|
public void setFieldSeparator(char fieldSeparator)
public void setTextDelimiter(char textDelimiter)
public void setAlwaysDelimitText(boolean alwaysDelimitText)
textDelimiter (default: false).public void setLineDelimiter(char[] lineDelimiter)
System.lineSeparator()).public void write(java.io.File file,
java.nio.charset.Charset charset,
java.util.Collection<java.lang.String[]> data)
throws java.io.IOException
file - where the data should be written to.data - lines/columns to be written.java.io.IOException - if a write error occursjava.lang.NullPointerException - if file, charset or data is nullpublic void write(java.nio.file.Path path,
java.nio.charset.Charset charset,
java.util.Collection<java.lang.String[]> data)
throws java.io.IOException
path - where the data should be written to.data - lines/columns to be written.java.io.IOException - if a write error occursjava.lang.NullPointerException - if path, charset or data is nullpublic void write(java.io.Writer writer,
java.util.Collection<java.lang.String[]> data)
throws java.io.IOException
writer - where the data should be written to.data - lines/columns to be written.java.io.IOException - if a write error occursjava.lang.NullPointerException - if writer or data is nullpublic CsvAppender append(java.io.File file, java.nio.charset.Charset charset) throws java.io.IOException
CsvAppender for the specified File.file - the file to write data to.charset - the character set to be used for writing data to the file.java.io.IOException - if a write error occursjava.lang.NullPointerException - if file or charset is nullpublic CsvAppender append(java.nio.file.Path path, java.nio.charset.Charset charset) throws java.io.IOException
CsvAppender for the specified Path.path - the Path (file) to write data to.charset - the character set to be used for writing data to the file.java.io.IOException - if a write error occursjava.lang.NullPointerException - if path or charset is nullpublic CsvAppender append(java.io.Writer writer)
CsvAppender for the specified Writer.
This library uses built-in buffering, so you do not need to pass in a buffered Writer
implementation such as BufferedWriter.
Performance may be even likely better if you do not.writer - the Writer to use for writing CSV data.java.lang.NullPointerException - if writer is null