Package scriptella.driver.csv.opencsv
Class CSVReader
java.lang.Object
scriptella.driver.csv.opencsv.CSVReader
- All Implemented Interfaces:
Closeable,AutoCloseable
A very simple CSV reader released under a commercial-friendly license.
- Author:
- Glen Smith, Fyodor Kupolov (Performance optimizations)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charThe default quote character to use if none is supplied to the constructor.static final charThe default separator to use if none is supplied to the constructor.static final intThe default line to start reading. -
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. -
Method Summary
-
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:
-
DEFAULT_SKIP_LINES
public static final int DEFAULT_SKIP_LINESThe default line to start reading.- See Also:
-
-
Constructor Details
-
CSVReader
Constructs CSVReader using a comma for the separator.- Parameters:
reader- the reader to an underlying CSV source.
-
CSVReader
Constructs CSVReader with supplied separator.- Parameters:
reader- the reader to an underlying CSV source.separator- the delimiter to use for separating entries.
-
CSVReader
Constructs CSVReader with supplied separator and quote char.- Parameters:
reader- the reader to an underlying CSV source.separator- the delimiter to use for separating entriesquotechar- the character to use for quoted elements
-
CSVReader
Constructs CSVReader with supplied separator and quote char.- Parameters:
reader- the reader to an underlying CSV source.separator- the delimiter to use for separating entriesquotechar- the character to use for quoted elementsline- the line number to skip for start reading
-
-
Method Details
-
readAll
Reads the entire file into a List with each element being a String[] of tokens.- Returns:
- a List of String[], with each String[] representing a line of the file.
- Throws:
IOException- if bad things happen during the read
-
readNext
Reads the next line from the buffer and converts to a string array.- Returns:
- a string array with each comma-separated element as a separate entry.
- Throws:
IOException- if bad things happen during the read
-
close
Closes the underlying reader.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if the close fails
-