public class CsvReader extends Object
Usage:final CsvReader csvReader = new CsvReader(reader, ';'); CsvReader.CsvToken token = csvReader.read(); while (token.getType() != CsvReader.CsvToken.EOF) if (token.getType() == CsvReader.CsvToken.NEW_LINE) // handle newline
else // handle value final String value = token.getValue(); } token = csvReader.read(); } }
Modifier and Type | Class and Description |
---|---|
static class |
CsvReader.CsvToken
Class representing a single token
|
Constructor and Description |
---|
CsvReader(Reader reader)
Constructs a new CsvReader with the given reader as source of the csv file with default delimiter ';'.
|
CsvReader(Reader reader,
char delim)
Constructs a new CsvReader with the given reader as source of the csv file and the given char as delimiter of the csv file
|
Modifier and Type | Method and Description |
---|---|
static List<List<String>> |
parseCsvToList(Reader reader,
char delim)
parses the csv source of the given reader to a list of lists of
String 's |
static String[][] |
parseCsvToStringArray(Reader reader,
char delim)
parses the csv source of the given reader to a StringArray of StringArrays
|
CsvReader.CsvToken |
read()
Returns a
CsvToken of the typeCsvReader.CsvToken.VALUE or CsvReader.CsvToken.NEW_LINE or CsvReader.CsvToken.EOF |
public CsvReader(@NotNull Reader reader, char delim)
reader
- reader for the csv filedelim
- the delimiter char of the csv file@NotNull public CsvReader.CsvToken read() throws IOException
CsvToken
of the typeCsvReader.CsvToken.VALUE
or CsvReader.CsvToken.NEW_LINE
or CsvReader.CsvToken.EOF
IOException
- from underlying streamCsvReader.CsvToken
@NotNull public static List<List<String>> parseCsvToList(@NotNull Reader reader, char delim) throws IllegalStateException
String
'sreader
- the reader for the csv filedelim
- the delimiter char of the csv fileIllegalStateException
- if the csv file is invalid, or if a IOException
is encounteredwhile reading@NotNull public static String[][] parseCsvToStringArray(@NotNull Reader reader, char delim) throws IllegalStateException
reader
- the reader for the csv filedelim
- the delimiter char of the csv fileIllegalStateException
- if the csv file is invalid, or if a IOException
is encounteredwhile readingCopyright © 2021 e-Spirit AG. All Rights Reserved. Build 5.2.210210