|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttextfile.DelimitedTextFile
A class which can locate and read a delimited text file and make the fields available line by line. By default, the file is assumed to be tab-delimited (has tabs separating the string fields on each line). Alternatively, another delimiter can be designated. There can be any number of fields on each line. Each field is taken to be a String. Within a field, no trimming or parsing is done. This class is just a wrapper for a DelimitedTextReader.
Field Summary | |
static java.lang.String |
DEFAULT_DELIMITER
The default delimiter used for splitting lines of text. |
Constructor Summary | |
DelimitedTextFile(java.lang.String filename)
Given a file name, find the file it refers to it and make it ready for read-access; the field delimiter is set to be the TAB character. |
|
DelimitedTextFile(java.lang.String filename,
java.lang.String delimiter)
Given a file name, find the file it refers to it and make it ready for read-access; the field delimiter is set to be the parameter value. |
Method Summary | |
java.lang.String |
getFileName()
Tells the name of the underlying file; may be a path or URL. |
int |
getLineNum()
Tells the number of the most recently read line. |
java.lang.String[] |
readLineAsFieldArray()
Read the next line of the file and parse it into fields. |
java.util.List |
readLineAsFieldList()
Return the data of the current line as a list of Strings; see readLineAsFieldArray(). |
java.lang.String |
toString()
Produce a summary of this object. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String DEFAULT_DELIMITER
Constructor Detail |
public DelimitedTextFile(java.lang.String filename)
filename
- a full or partial file name or URL.public DelimitedTextFile(java.lang.String filename, java.lang.String delimiter)
filename
- a full or partial filename or URL; may not be
empty or null.delimiter
- the string which delimits fields on each line of
the file. This is typically a single character, such as TAB, but
it can be any regular expression; may not be empty or null.
java.lang.IllegalArgumentException
- if a parameter value is bad.Method Detail |
public java.lang.String[] readLineAsFieldArray()
public java.util.List readLineAsFieldList()
public int getLineNum()
public java.lang.String getFileName()
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |