public class CsvReader extends CsvBase
Enables you to read CSV-files using various types of delimiters (column and row) and quotes.
columnSeparator, DEFAULT_COLUMN_SEPARATOR, DEFAULT_FIELD_DELIMITER, DEFAULT_ROW_SEPARATOR, fieldDelimiter, lockObject, rowSeparator
Constructor and Description |
---|
CsvReader(@Nullable StringReader stringReader)
Initializes a new instance of the CsvReader class.
|
CsvReader(@Nullable StringReader stringReader,
@Nullable Character columnSeparator,
@Nullable String rowSeparator,
@Nullable String fieldDelimiter,
@Nullable Integer readChunkSize)
Initializes a new instance of the CsvReader class.
|
CsvReader(@Nullable StringReader stringReader,
char columnSeparator,
String rowSeparator,
String fieldDelimiter)
Initializes a new instance of the CsvReader class.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected void |
finalize() |
@Nullable List<List<String>> |
readAllRows()
Reads all rows of the CSV and returns them in a List.
|
@Nullable List<String> |
readRow()
Returns the next row, already split into fields.
|
public CsvReader(@Nullable @Nullable StringReader stringReader) throws IllegalArgumentException
stringReader
- The StringReader you want the CsvReader to attach to.IllegalArgumentException
- If the provided stringReader is null.public CsvReader(@Nullable @Nullable StringReader stringReader, char columnSeparator, String rowSeparator, String fieldDelimiter)
stringReader
- The StringReader you want the CsvReader 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 CsvReader(@Nullable @Nullable StringReader stringReader, @Nullable @Nullable Character columnSeparator, @Nullable @Nullable String rowSeparator, @Nullable @Nullable String fieldDelimiter, @Nullable @Nullable Integer readChunkSize)
stringReader
- The StringReader you want the CsvReader 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).readChunkSize
- 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).@Nullable public @Nullable List<String> readRow() throws IOException
IOException
- If the underlying stream could not be accessed.@Nullable public @Nullable List<List<String>> readAllRows() throws IOException
IOException
- If the underlying stream could not be accessed.public void close() throws IOException
IOException
Copyright © 2016 Unterrainer Informatik OG. All rights reserved.