Package org.supercsv.io
Interface ICsvReader
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Subinterfaces:
ICsvBeanReader
,ICsvListReader
,ICsvMapReader
- All Known Implementing Classes:
AbstractCsvReader
,CsvBeanReader
,CsvListReader
,CsvMapReader
The interface for CSV readers.
-
Method Summary
Modifier and TypeMethodDescriptionget
(int n) Get column N of the current line (column indexes begin at 1).String[]
getHeader
(boolean firstLineCheck) This method is used to get an optional header of the CSV file and move the file cursor to the first row containing data (the second row from the top).int
Gets the current position in the file, where the first line of the file is line number 1.int
Gets the current row number (i.e.Returns the untokenized CSV row that was just read (which can potentially span multiple lines in the file).int
length()
Returns the length (i.e.
-
Method Details
-
get
Get column N of the current line (column indexes begin at 1).- Parameters:
n
- the index of the column to get- Returns:
- the n'th column
- Throws:
IndexOutOfBoundsException
- if the supplied index is not a valid column index- Since:
- 1.0
-
getHeader
This method is used to get an optional header of the CSV file and move the file cursor to the first row containing data (the second row from the top). The header can subsequently be used as thenameMapping
array for read operations.- Parameters:
firstLineCheck
- if true, ensures that this method is only called when reading the first line (as that's where the header is meant to be)- Returns:
- the array of header fields, or null if EOF is encountered
- Throws:
IOException
- if an I/O exception occursSuperCsvException
- if firstLineCheck == true and it's not the first line being read- Since:
- 1.0
-
getLineNumber
int getLineNumber()Gets the current position in the file, where the first line of the file is line number 1.- Returns:
- the line number
- Since:
- 1.0
-
getUntokenizedRow
String getUntokenizedRow()Returns the untokenized CSV row that was just read (which can potentially span multiple lines in the file).- Returns:
- the untokenized CSV row that was just read
- Since:
- 2.0.0
-
getRowNumber
int getRowNumber()Gets the current row number (i.e. the number of CSV records - including the header - that have been read). This differs from the lineNumber, which is the number of real lines that have been read in the file. The first row is row 1 (which is typically the header row).- Returns:
- the current row number
- Since:
- 2.0.0
-
length
int length()Returns the length (i.e. number of columns) of the current row.- Returns:
- the length of the current row
- Since:
- 1.0
-