Package org.supercsv.io
Interface ICsvReader
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
- All Known Subinterfaces:
ICsvBeanReader
,ICsvListReader
,ICsvMapReader
- All Known Implementing Classes:
AbstractCsvReader
,CsvBeanReader
,CsvListReader
,CsvMapReader
public interface ICsvReader extends java.io.Closeable
The interface for CSV readers.- Author:
- Kasper B. Graversen, James Bassett
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
get(int n)
Get column N of the current line (column indexes begin at 1).java.lang.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
getLineNumber()
Gets the current position in the file, where the first line of the file is line number 1.int
getRowNumber()
Gets the current row number (i.e.java.lang.String
getUntokenizedRow()
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 Detail
-
get
java.lang.String get(int n)
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:
java.lang.IndexOutOfBoundsException
- if the supplied index is not a valid column index- Since:
- 1.0
-
getHeader
java.lang.String[] getHeader(boolean firstLineCheck) throws java.io.IOException
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:
java.io.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
java.lang.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
-
-