CSVReader.
This should be the preferred method of creating a Reader as there are so many
possible values to be set it is impossible to have constructors for all of
them and keep backwards compatibility with previous constructors.
final CSVParser parser =
new CSVParserBuilder()
.withSeparator('\t')
.withIgnoreQuotations(true)
.build();
final CSVReader reader =
new CSVReaderBuilder(new StringReader(csv))
.withSkipLines(1)
.withCSVParser(parser)
.build();
com.opencsv.CSVReader
| Access | Constructor and Description |
|---|---|
| public | CSVReaderBuilder(final Reader
The reader to an underlying CSV source. reader)Sets the reader to an underlying CSV source. |
| Modifier and Type | Method and Description |
|---|---|
| public CSVReader | Returns: TheCSVReader based on the set criteria.Implements abstract com. Creates the |
| public CSVReaderBuilder | Returns: thisThe parser to use to parse the input. icsvParser)Sets the parser to use to parse the input. |
| public CSVReaderBuilder | Returns: thisLocale for error messages errorLocale)Sets the locale for all error messages. |
| public CSVReaderBuilder | Returns: thisCSVReaderNullFieldIndicator set to what should be considered a null field.Checks to see if it should treat a field with two separators, two quotes, or both as a null field. |
| public CSVReaderBuilder | Returns: thisTrue to keep carriage returns, false to discard. keepCR)Sets if the reader will keep or discard carriage returns. |
| public CSVReaderBuilder | Returns: thisLineValidator to inject.Adds a |
| public CSVReaderBuilder | Returns: thisNo more than this number of lines is allowed in a
single input record. The default is multilineLimit)CSVReader#DEFAULT_MULTILINE_LIMIT.Sets the maximum number of lines allowed in a multiline record. |
| public CSVReaderBuilder | Returns: thisRowProcessor to injectAdds a |
| public CSVReaderBuilder | Returns: thisRowValidator to injectAdds a |
| public CSVReaderBuilder | Returns: thisThe number of lines to skip before reading. skipLines)Sets the number of lines to skip before reading. |
| public CSVReaderBuilder | Returns: thisTrue if verifyReader)CSVReader should verify reader before each read, false otherwise.Checks to see if the |
| CSVReaderBuilder | back to summary |
|---|---|
| public CSVReaderBuilder(final Reader reader) Sets the reader to an underlying CSV source.
| |
| build | back to summary |
|---|---|
| public CSVReader build() Implements abstract com. Creates the | |
| withCSVParser | back to summary |
|---|---|
| public CSVReaderBuilder withCSVParser(final ICSVParser icsvParser) Sets the parser to use to parse the input.
| |
| withErrorLocale | back to summary |
|---|---|
| public CSVReaderBuilder withErrorLocale(Locale errorLocale) Sets the locale for all error messages.
| |
| withFieldAsNull | back to summary |
|---|---|
| public CSVReaderBuilder withFieldAsNull(CSVReaderNullFieldIndicator indicator) Checks to see if it should treat a field with two separators, two quotes, or both as a null field.
| |
| withKeepCarriageReturn | back to summary |
|---|---|
| public CSVReaderBuilder withKeepCarriageReturn(boolean keepCR) Sets if the reader will keep or discard carriage returns.
| |
| withLineValidator | back to summary |
|---|---|
| public CSVReaderBuilder withLineValidator(LineValidator lineValidator) Adds a
| |
| withMultilineLimit | back to summary |
|---|---|
| public CSVReaderBuilder withMultilineLimit(int multilineLimit) Sets the maximum number of lines allowed in a multiline record. More than this number in one record results in an IOException.
| |
| withRowProcessor | back to summary |
|---|---|
| public CSVReaderBuilder withRowProcessor(RowProcessor rowProcessor) Adds a
| |
| withRowValidator | back to summary |
|---|---|
| public CSVReaderBuilder withRowValidator(RowValidator rowValidator) Adds a
| |
| withSkipLines | back to summary |
|---|---|
| public CSVReaderBuilder withSkipLines(final int skipLines) Sets the number of lines to skip before reading.
| |
| withVerifyReader | back to summary |
|---|---|
| public CSVReaderBuilder withVerifyReader(boolean verifyReader) Checks to see if the This should be set to false if you are using some form of asynchronous reader (like readers created by the java.nio.* classes). The default value is true.
| |