public class CSVReader extends Object
| Modifier and Type | Field and Description |
|---|---|
static char |
NO_QUOTS
Constant
NO_QUOTS=0 |
| Constructor and Description |
|---|
CSVReader(Reader r)
convenience Constructor, default to comma separator, " for quote, no
multiline fields, with trimming.
|
CSVReader(Reader r,
char separator,
char quote,
boolean allowMultiLineFields,
boolean trim)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the Reader.
|
String |
get()
Read one field from the CSV file
|
String |
get(int row)
get.
|
String |
get(String row)
get.
|
String[] |
getAllFieldsInLine()
Get all fields in the line
|
double |
getDouble()
Read one double field from the CSV file.
|
float |
getFloat()
Read one float field from the CSV file.
|
int |
getInt()
Read one integer field from the CSV file
|
int |
getLineCount()
Getter for the field
lineCount. |
long |
getLong()
Read one long field from the CSV file
|
String[] |
getRowNames()
getRowNames.
|
static void |
main(String[] args)
Test driver
|
boolean |
next()
next.
|
void |
readHeader(boolean lower)
readHeader.
|
void |
skip(int fields)
Skip over fields you don't want to process.
|
void |
skipToNextLine()
Skip over remaining fields on this line you don't want to process.
|
public static final char NO_QUOTS
NO_QUOTS=0public CSVReader(Reader r)
r - input Reader source of CSV Fields to read.public CSVReader(Reader r, char separator, char quote, boolean allowMultiLineFields, boolean trim)
r - input Reader source of CSV Fields to read.separator - field separator character, usually ',' in North America, ';'
in Europe and sometimes '\t' for tab.quote - char to use to enclose fields containing a separator, usually
'\"'allowMultiLineFields - true if reader should allow quoted fields to span more than
one line. Microsoft Excel sometimes generates files like this.trim - true if reader should trim lead/trailing whitespace e.g.
blanks, Cr, Lf. Tab off fields.public void close()
throws IOException
IOException - if any.public String get() throws EOFException, IOException
EOFException - at end of file after all the fields have been read.IOException - Some problem reading the file, possibly malformed data.public String[] getAllFieldsInLine() throws EOFException, IOException
EOFException - if any.IOException - if any.public double getDouble()
throws EOFException,
IOException,
NumberFormatException
EOFException - at end of file after all the fields have been read.IOException - Some problem reading the file, possibly malformed data.NumberFormatException - if any.public float getFloat()
throws EOFException,
IOException,
NumberFormatException
EOFException - at end of file after all the fields have been read.IOException - Some problem reading the file, possibly malformed data.NumberFormatException - if any.public int getInt()
throws EOFException,
IOException,
NumberFormatException
EOFException - at end of file after all the fields have been read.IOException - Some problem reading the file, possibly malformed data.NumberFormatException - if any.public long getLong()
throws EOFException,
IOException,
NumberFormatException
EOFException - at end of file after all the fields have been read.IOException - Some problem reading the file, possibly malformed data.NumberFormatException - if any.public void skip(int fields)
throws EOFException,
IOException
fields - How many field you want to bypass reading. The newline counts
as one field.EOFException - at end of file after all the fields have been read.IOException - Some problem reading the file, possibly malformed data.public void skipToNextLine()
throws EOFException,
IOException
EOFException - at end of file after all the fields have been read.IOException - Some problem reading the file, possibly malformed data.public void readHeader(boolean lower)
throws EOFException,
IOException
readHeader.
lower - a boolean.EOFException - if any.IOException - if any.public boolean next()
throws IOException
next.
IOException - if any.public String get(String row) throws IOException
get.
row - a String object.String object.IOException - if any.public int getLineCount()
Getter for the field lineCount.
public static void main(String[] args)
args - not usedCopyright © 2016. All Rights Reserved.