public class CSVLines extends PeekIterator<List<String>>
for(List<String> 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 List<String> |
columns
Holds the column names
|
protected Reader |
in
Containes the Reader
|
protected int |
nextChar
Holds the next char in line
|
protected char |
separator
Holds the spearator
|
closed, EMPTY, fetchedNextValue, next| Constructor and Description |
|---|
CSVLines(File f)
Constructs a CSVReader
|
CSVLines(Reader reader)
Constructs a CSVReader
|
CSVLines(String file)
Constructs a CSVReader
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the underlying resource
|
List<String> |
columnNames()
returns the column names (or NULL)
|
protected String |
component()
Reads a component and the following comma
|
protected List<String> |
internalNext()
Returns the next or NULL if no next element is available
|
static void |
main(String[] args)
Test method
|
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, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEachRemainingforEach, spliteratorprotected long announceChars
protected Reader in
protected int nextChar
protected char separator
public CSVLines(File f) throws IOException
IOExceptionpublic CSVLines(Reader reader) throws IOException
IOExceptionpublic CSVLines(String file) throws IOException
IOExceptionpublic void setSeparator(char s)
protected String component() throws IOException
IOExceptionprotected List<String> internalNext() throws Exception
PeekIteratorinternalNext in class PeekIterator<List<String>>Exceptionpublic Integer numColumns()
public void close()
PeekIteratorclose in interface Closeableclose in interface AutoCloseableclose in class PeekIterator<List<String>>Copyright © 2018. All rights reserved.