public class CSVLines extends PeekIterator<java.util.List<java.lang.String>>
for(List columns : new CSVFile("c:\\autoexec.csv")) {
System.out.println(columns);
}
Recognizes column headers if introduced by '#'. Recognizes all types of encodings (see Char.decode()).PeekIterator.ElementaryPeekIterator<T>, PeekIterator.SimplePeekIterator<T>| Modifier and Type | Field and Description |
|---|---|
protected long |
announceChars
number of chars for announce (or -1)
|
protected java.util.List<java.lang.String> |
columns
Holds the column names
|
protected java.io.Reader |
in
Containes the Reader
|
protected int |
nextChar
Holds the next char in line
|
protected char |
separator
Holds the spearator
|
closed, EMPTY, initialized, next| Constructor and Description |
|---|
CSVLines(java.io.File f)
Constructs a CSVReader
|
CSVLines(java.io.Reader reader)
Constructs a CSVReader
|
CSVLines(java.lang.String file)
Constructs a CSVReader
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the underlying resource
|
java.util.List<java.lang.String> |
columnNames()
returns the column names (or NULL)
|
protected java.lang.String |
component()
Reads a component and the following comma
|
protected java.util.List<java.lang.String> |
internalNext()
Returns the next or NULL if no next element is available
|
static void |
main(java.lang.String[] args)
Test method
|
java.lang.Integer |
numColumns()
returns the number of columns (or NULL)
|
void |
setSeparator(char s)
Sets the separator (comma by default)
|
asList, asList, asSet, asSet, asSet, emptyIterator, hasNext, internalSilentNext, iterator, list, list, next, nextOrNull, numElements, numElements, peek, remove, toString, toString, toStringprotected long announceChars
protected java.io.Reader in
protected java.util.List<java.lang.String> columns
protected int nextChar
protected char separator
public CSVLines(java.io.File f)
throws java.io.IOException
java.io.IOExceptionpublic CSVLines(java.io.Reader reader)
throws java.io.IOException
java.io.IOExceptionpublic CSVLines(java.lang.String file)
throws java.io.IOException
java.io.IOExceptionpublic void setSeparator(char s)
protected java.lang.String component()
throws java.io.IOException
java.io.IOExceptionprotected java.util.List<java.lang.String> internalNext()
throws java.lang.Exception
PeekIteratorinternalNext in class PeekIterator<java.util.List<java.lang.String>>java.lang.Exceptionpublic java.util.List<java.lang.String> columnNames()
public java.lang.Integer numColumns()
public void close()
PeekIteratorclose in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class PeekIterator<java.util.List<java.lang.String>>public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception