public static final class CsvReader.CsvReaderBuilder
extends java.lang.Object
CsvReader. The default
configuration of this class complies with RFC 4180.
The line delimiter (line-feed, carriage-return or the combination of both) is detected automatically and thus not configurable.
| Modifier and Type | Method and Description |
|---|---|
CsvReader |
build(java.nio.file.Path path)
Constructs a new
CsvReader for the specified path using UTF-8 as the character set. |
CsvReader |
build(java.nio.file.Path path,
java.nio.charset.Charset charset)
Constructs a new
CsvReader for the specified arguments. |
CsvReader |
build(java.io.Reader reader)
Constructs a new
CsvReader for the specified arguments. |
CsvReader |
build(java.lang.String data)
Constructs a new
CsvReader for the specified arguments. |
CsvReader.CsvReaderBuilder |
commentCharacter(char commentCharacter)
Sets the
commentCharacter used to comment lines. |
CsvReader.CsvReaderBuilder |
commentStrategy(CommentStrategy commentStrategy)
Sets the strategy that defines how (and if) commented lines should be handled
(default:
CommentStrategy.NONE as comments are not defined in RFC 4180). |
CsvReader.CsvReaderBuilder |
errorOnDifferentFieldCount(boolean errorOnDifferentFieldCount)
Defines if an
MalformedCsvException should be thrown if lines do contain a
different number of columns. |
CsvReader.CsvReaderBuilder |
fieldSeparator(char fieldSeparator)
Sets the
fieldSeparator used when reading CSV data. |
CsvReader.CsvReaderBuilder |
quoteCharacter(char quoteCharacter)
Sets the
quoteCharacter used when reading CSV data. |
CsvReader.CsvReaderBuilder |
skipEmptyRows(boolean skipEmptyRows)
Defines if empty rows should be skipped when reading data.
|
java.lang.String |
toString() |
public CsvReader.CsvReaderBuilder fieldSeparator(char fieldSeparator)
fieldSeparator used when reading CSV data.fieldSeparator - the field separator character (default: , - comma).public CsvReader.CsvReaderBuilder quoteCharacter(char quoteCharacter)
quoteCharacter used when reading CSV data.quoteCharacter - the character used to enclose fields
(default: " - double quotes).public CsvReader.CsvReaderBuilder commentStrategy(CommentStrategy commentStrategy)
CommentStrategy.NONE as comments are not defined in RFC 4180).commentStrategy - the strategy for handling comments.commentCharacter(char)public CsvReader.CsvReaderBuilder commentCharacter(char commentCharacter)
commentCharacter used to comment lines.commentCharacter - the character used to comment lines (default: # - hash)commentStrategy(CommentStrategy)public CsvReader.CsvReaderBuilder skipEmptyRows(boolean skipEmptyRows)
skipEmptyRows - if empty rows should be skipped (default: true).public CsvReader.CsvReaderBuilder errorOnDifferentFieldCount(boolean errorOnDifferentFieldCount)
MalformedCsvException should be thrown if lines do contain a
different number of columns.errorOnDifferentFieldCount - if an exception should be thrown, if CSV data contains
different field count (default: false).public CsvReader build(java.io.Reader reader)
CsvReader for the specified arguments.
This library uses built-in buffering, so you do not need to pass in a buffered Reader
implementation such as BufferedReader. Performance may be even likely
better if you do not.
Use build(Path, Charset) for optimal performance when
reading files and build(String) when reading Strings.
reader - the data source to read from.null.java.lang.NullPointerException - if reader is nullpublic CsvReader build(java.lang.String data)
CsvReader for the specified arguments.data - the data to read.null.public CsvReader build(java.nio.file.Path path) throws java.io.IOException
CsvReader for the specified path using UTF-8 as the character set.path - the file to read data from.null. Don't forget to close it!java.io.IOException - if an I/O error occurs.java.lang.NullPointerException - if path or charset is nullpublic CsvReader build(java.nio.file.Path path, java.nio.charset.Charset charset) throws java.io.IOException
CsvReader for the specified arguments.path - the file to read data from.charset - the character set to use.null. Don't forget to close it!java.io.IOException - if an I/O error occurs.java.lang.NullPointerException - if path or charset is nullpublic java.lang.String toString()
toString in class java.lang.Object