Class CSVReader
java.lang.Object
ca.phon.csv.CSVReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
Reads data from a CSV file with specified settings.
We escape fields based on the rules defined in RFC4180.
- Author:
- Cristopher Yates
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new CSVReader.CSVReader
(Reader reader, char[] separators, CSVQuoteType quoteChar) CSVReader
(Reader reader, char[] separators, CSVQuoteType quoteChar, boolean trimSpaces) Constructs a new CSVReader.CSVReader
(Reader reader, CSVQuoteType quoteChar) CSVReader
(Reader reader, CSVQuoteType quoteChar, boolean trimSpaces) -
Method Summary
-
Constructor Details
-
CSVReader
Constructs a new CSVReader.- Parameters:
reader
- The reader that the data is read from.
-
CSVReader
-
CSVReader
-
CSVReader
-
CSVReader
-
CSVReader
-
CSVReader
-
CSVReader
Constructs a new CSVReader.- Parameters:
reader
- The reader that the data is read from.separators
- The characters that signal the end of a field and beginning of another.quoteChar
- The type of quote used to enclose escaped fields (single or double).trimSpaces
- Whether to remove any leading or trailing whitespace.
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
readNext
Reads the next record from the reader.- Returns:
- The record as a string array of the fields.
- Throws:
IOException
-
readAll
Read all records in csv data- Returns:
- list of string arrays
- Throws:
IOException
-