Package org.openforis.commons.io.csv
Class CsvReader
- java.lang.Object
-
- org.openforis.commons.io.csv.CsvProcessor
-
- org.openforis.commons.io.csv.CsvReader
-
- All Implemented Interfaces:
Closeable,AutoCloseable,FlatDataStream
public class CsvReader extends CsvProcessor implements FlatDataStream, Closeable
- Author:
- G. Miceli, M. Togna, S. Ricci
-
-
Field Summary
Fields Modifier and Type Field Description static charDEFAULT_QUOTE_CHARACTERstatic charDEFAULT_SEPARATOR
-
Constructor Summary
Constructors Constructor Description CsvReader(File file)CsvReader(File file, char separator, char quoteChar)CsvReader(File file, String charsetName, char separator, char quoteChar)CsvReader(Reader reader)Deprecated.CallCsvReader(File)instead.CsvReader(Reader reader, char separator, char quoteChar)Deprecated.CallCsvReader(File, char, char)instead.CsvReader(String filename)CsvReader(String fileName, char separator, char quoteChar)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()List<String>getColumnNames()DateFormatgetDateFormat()List<String>getFieldNames()List<Field>getFields()longgetLinesRead()booleanisHeadersRead()FlatRecordnextRecord()voidreadHeaders()CsvLinereadNextLine()voidsetHeadersRead(boolean headersRead)intsize()Returns the number of lines including the headers-
Methods inherited from class org.openforis.commons.io.csv.CsvProcessor
setDateFormat, setDateFormat, setFieldNames, setFields, setFields
-
-
-
-
Field Detail
-
DEFAULT_SEPARATOR
public static final char DEFAULT_SEPARATOR
- See Also:
- Constant Field Values
-
DEFAULT_QUOTE_CHARACTER
public static final char DEFAULT_QUOTE_CHARACTER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CsvReader
public CsvReader(String filename) throws FileNotFoundException
- Throws:
FileNotFoundException
-
CsvReader
public CsvReader(String fileName, char separator, char quoteChar) throws FileNotFoundException
- Throws:
FileNotFoundException
-
CsvReader
public CsvReader(File file) throws FileNotFoundException
- Throws:
FileNotFoundException
-
CsvReader
public CsvReader(File file, char separator, char quoteChar) throws FileNotFoundException
- Throws:
FileNotFoundException
-
CsvReader
public CsvReader(File file, String charsetName, char separator, char quoteChar) throws FileNotFoundException
- Throws:
FileNotFoundException
-
CsvReader
@Deprecated public CsvReader(Reader reader)
Deprecated.CallCsvReader(File)instead.
-
CsvReader
@Deprecated public CsvReader(Reader reader, char separator, char quoteChar)
Deprecated.CallCsvReader(File, char, char)instead.
-
-
Method Detail
-
readHeaders
public void readHeaders() throws IOException- Throws:
IOException
-
readNextLine
public CsvLine readNextLine() throws IOException
- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
isHeadersRead
public boolean isHeadersRead()
-
setHeadersRead
public void setHeadersRead(boolean headersRead)
-
getLinesRead
public long getLinesRead()
-
getFields
public List<Field> getFields()
- Specified by:
getFieldsin interfaceFlatDataStream- Overrides:
getFieldsin classCsvProcessor
-
getFieldNames
public List<String> getFieldNames()
- Overrides:
getFieldNamesin classCsvProcessor
-
nextRecord
public FlatRecord nextRecord() throws IOException
- Specified by:
nextRecordin interfaceFlatDataStream- Throws:
IOException
-
getDateFormat
public DateFormat getDateFormat()
- Overrides:
getDateFormatin classCsvProcessor
-
size
public int size() throws IOExceptionReturns the number of lines including the headers- Returns:
- Throws:
IOException
-
-