Package de.espirit.common.util
Class CsvReader
java.lang.Object
de.espirit.common.util.CsvReader
Utility class to parse CSV files.
 
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(); }
- Since:
 - 5.1.28
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classClass representing a single token - 
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new CsvReader with the given reader as source of the csv file with default delimiter ';'.Constructs a new CsvReader with the given reader as source of the csv file and the given char as delimiter of the csv file - 
Method Summary
Modifier and TypeMethodDescriptionparseCsvToList(@NotNull Reader reader, char delim) parses the csv source of the given reader to a list of lists ofString'sstatic @NotNull String[][]parseCsvToStringArray(@NotNull Reader reader, char delim) parses the csv source of the given reader to a StringArray of StringArrays@NotNull CsvReader.CsvTokenread()Returns aCsvTokenof the typeCsvReader.CsvToken.VALUEorCsvReader.CsvToken.NEW_LINEorCsvReader.CsvToken.EOF 
- 
Constructor Details
- 
CsvReader
Constructs a new CsvReader with the given reader as source of the csv file and the given char as delimiter of the csv file- Parameters:
 reader- reader for the csv filedelim- the delimiter char of the csv file- Since:
 - 5.1.28
 
 - 
CsvReader
Constructs a new CsvReader with the given reader as source of the csv file with default delimiter ';'.- Parameters:
 reader- reader for the csv file- Since:
 - 5.1.28
 
 
 - 
 - 
Method Details
- 
read
Returns aCsvTokenof the typeCsvReader.CsvToken.VALUEorCsvReader.CsvToken.NEW_LINEorCsvReader.CsvToken.EOF- Returns:
 - CsvToken - currentToken
 - Throws:
 IOException- from underlying stream- Since:
 - 5.1.28
 - See Also:
 
 - 
parseCsvToList
@NotNull public static @NotNull List<List<String>> parseCsvToList(@NotNull @NotNull Reader reader, char delim) throws IllegalStateException parses the csv source of the given reader to a list of lists ofString's- Parameters:
 reader- the reader for the csv filedelim- the delimiter char of the csv file- Returns:
 - List - a List of Lists
 - Throws:
 IllegalStateException- if the csv file is invalid, or if aIOExceptionis encountered while reading- Since:
 - 5.1.28
 
 - 
parseCsvToStringArray
@NotNull public static @NotNull String[][] parseCsvToStringArray(@NotNull @NotNull Reader reader, char delim) throws IllegalStateException parses the csv source of the given reader to a StringArray of StringArrays- Parameters:
 reader- the reader for the csv filedelim- the delimiter char of the csv file- Returns:
 - String[][] - a StringArray of StringArrays
 - Throws:
 IllegalStateException- if the csv file is invalid, or if aIOExceptionis encountered while reading- Since:
 - 5.1.28
 
 
 -