Class CsvReader
java.lang.Object
com.aquima.interactions.framework.util.textdata.AbstractTextDataReader
com.aquima.interactions.framework.util.textdata.CsvReader
This class can be used to read a CSV (Comma Separated Values) resource.
- Since:
- 6.3
- Author:
- Jon van Leuven
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final char
The default quote character to use if none is supplied to the constructor.static final char
The default separator to use if none is supplied to the constructor.Fields inherited from class com.aquima.interactions.framework.util.textdata.AbstractTextDataReader
DEFAULT_SKIP_LINES
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs csvReader using a comma for the separator.Constructs csvReader with supplied separator.Constructs csvReader with supplied separator and quote char.Constructs csvReader with supplied separator and quote char.Constructs csvReader with supplied separator ,quote char and charset.Constructs csvReader with supplied separator ,quote char and charset. -
Method Summary
Methods inherited from class com.aquima.interactions.framework.util.textdata.AbstractTextDataReader
close, getNextLine, readAll, readNext
-
Field Details
-
DEFAULT_SEPARATOR
public static final char DEFAULT_SEPARATORThe default separator to use if none is supplied to the constructor.- See Also:
-
DEFAULT_QUOTE_CHARACTER
public static final char DEFAULT_QUOTE_CHARACTERThe default quote character to use if none is supplied to the constructor.- See Also:
-
-
Constructor Details
-
CsvReader
Constructs csvReader using a comma for the separator.- Parameters:
resource
- the resource to an underlying csv source.- Throws:
ResourceException
- Occurs when problem reading the csv source.
-
CsvReader
Constructs csvReader with supplied separator.- Parameters:
resource
- the resource to an underlying csv source.separator
- the delimiter to use for separating entries.- Throws:
ResourceException
- Occurs when problem reading the csv source.
-
CsvReader
Constructs csvReader with supplied separator and quote char.- Parameters:
resource
- the resource to an underlying csv source.separator
- the delimiter to use for separating entriesquotechar
- the character to use for quoted elements- Throws:
ResourceException
- Occurs when problem reading the csv source.
-
CsvReader
Constructs csvReader with supplied separator ,quote char and charset.- Parameters:
resource
- the resource to an underlying csv source.separator
- the delimiter to use for separating entriesquotechar
- the character to use for quoted elementscharset
- the charset to use for decoding- Throws:
ResourceException
- Occurs when problem reading the csv source.
-
CsvReader
Constructs csvReader with supplied separator and quote char.- Parameters:
resource
- the resource to an underlying csv source.separator
- the delimiter to use for separating entriesquotechar
- the character to use for quoted elementsskipLines
- the line number to skip for start reading- Throws:
ResourceException
- Occurs when problem reading the csv source.
-
CsvReader
Constructs csvReader with supplied separator ,quote char and charset.- Parameters:
resource
- the resource to an underlying csv source.separator
- the delimiter to use for separating entriesquotechar
- the character to use for quoted elementsskipLines
- the line number to skip for start readingcharset
- the charset to use for decoding- Throws:
ResourceException
- Occurs when problem reading the csv source.
-
-
Method Details
-
parseLine
Parses an incoming String and returns an array of elements.- Specified by:
parseLine
in classAbstractTextDataReader
- Parameters:
nextLine
- the string to parse- Returns:
- the comma-tokenized list of elements, or null if nextLine is null
- Throws:
IOException
- if bad things happen during the read
-