|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectCSVFile
CSVFileReader
public class CSVFileReader
CSVFileReader is a class derived from CSVFile used to parse an existing CSV file.
Adapted from a C++ original that is Copyright (C) 1999 Lucent Technologies.
Excerpted from 'The Practice of Programming' by Brian Kernighan and Rob Pike.
Included by permission of the Addison-Wesley web site, which says: "You may use this code for any purpose, as long as you leave the copyright notice and book citation attached".
| Field Summary | |
|---|---|
protected java.io.BufferedReader |
in
The buffered reader linked to the CSV file to be read. |
| Fields inherited from class CSVFile |
|---|
DEFAULT_FIELD_SEPARATOR, DEFAULT_TEXT_QUALIFIER, fieldSeparator, textQualifier |
| Constructor Summary | |
|---|---|
CSVFileReader(java.lang.String inputFileName)
CSVFileReader constructor just need the name of the existing CSV file that will be read. |
|
CSVFileReader(java.lang.String inputFileName,
char sep)
CSVFileReader constructor with a given field separator. |
|
CSVFileReader(java.lang.String inputFileName,
char sep,
char qual)
CSVFileReader constructor with given field separator and text qualifier. |
|
| Method Summary | |
|---|---|
void |
close()
Close the input CSV file. |
protected int |
handlePlainField(java.lang.String s,
java.lang.StringBuffer sb,
int i)
Handles an unquoted field. |
protected int |
handleQuotedField(java.lang.String s,
java.lang.StringBuffer sb,
int i)
Handles a quoted field. |
java.util.Vector<java.lang.String> |
readFields()
Split the next line of the input CSV file into fields. |
| Methods inherited from class CSVFile |
|---|
getFieldSeparator, getTextQualifier, setFieldSeparator, setTextQualifier |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.io.BufferedReader in
| Constructor Detail |
|---|
public CSVFileReader(java.lang.String inputFileName)
throws java.io.FileNotFoundException
inputFileName - The name of the CSV file to be opened for reading
java.io.FileNotFoundException - If the file to be read does not exist
public CSVFileReader(java.lang.String inputFileName,
char sep)
throws java.io.FileNotFoundException
inputFileName - The name of the CSV file to be opened for readingsep - The field separator to be used; overwrites the default one
java.io.FileNotFoundException - If the file to be read does not exist
public CSVFileReader(java.lang.String inputFileName,
char sep,
char qual)
throws java.io.FileNotFoundException
inputFileName - The name of the CSV file to be opened for readingsep - The field separator to be used; overwrites the default onequal - The text qualifier to be used; overwrites the default one
java.io.FileNotFoundException - If the file to be read does not exist| Method Detail |
|---|
public java.util.Vector<java.lang.String> readFields()
throws java.io.IOException
This is currently the most important function of the package.
java.io.IOException - If an error occurs while reading the new line from the file
public void close()
throws java.io.IOException
java.io.IOException - If an error occurs while closing the file
protected int handleQuotedField(java.lang.String s,
java.lang.StringBuffer sb,
int i)
protected int handlePlainField(java.lang.String s,
java.lang.StringBuffer sb,
int i)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||