|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectorg.melati.poem.csv.CSVFileParser
public class CSVFileParser
A utility for tokenising a file made up of comma-separated variables. We allow for fields having returns in them.
foo, bar om,,"baz, ,oof",xyz, ->
"foo", " bar om", "", "baz, , oof", "xyz", ""
foo, "bar
bar
bar", baz ->
"foo", "barbarbar", "baz"
Each record (which is usually a line, unless some fields have
a line break in them) is accessed one at a time by calling
nextRecord(). Within each record
recordHasMoreFields() and nextField()
can be used like an Enumeration to iterate through the fields.
| Constructor Summary | |
|---|---|
CSVFileParser(BufferedReader reader)
Constructor. |
|
| Method Summary | |
|---|---|
int |
getLineNo()
Return the line number. |
static void |
main(String[] args)
Test harness. |
String |
nextField()
|
boolean |
nextRecord()
|
boolean |
recordHasMoreFields()
Are there any more tokens to come? |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CSVFileParser(BufferedReader reader)
reader - file reader| Method Detail |
|---|
public boolean nextRecord()
throws IOException
IOExceptionpublic int getLineNo()
public boolean recordHasMoreFields()
public String nextField()
throws IOException
IOException
public static void main(String[] args)
throws Exception
args - arguments
Exception - if anything fails
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||