public class RFC4180CSVParser extends Object implements Iterable<String[]>, Closeable
BufferedReader's end of line handling, so it will
swallow '\n', '\r' or '\r\n' line endings.
It attempts to implement the subset of RFV4180 called out on wikipedia:
Mainly, I implemented this simple subset because it is ... useful. If you need more than this, use a real library, like the excellent Apache one or OpenCSV, or, or, or.
| Constructor and Description |
|---|
RFC4180CSVParser(boolean hasHeader,
Reader reader)
Constructor, specifying if there is a header to read.
|
RFC4180CSVParser(char sep,
boolean hasHeader,
Reader reader)
Constructor, specifying field separator, and if there is a header to read.
|
RFC4180CSVParser(Reader reader)
Constructor, no header, comma seperator
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close this, close the reader.
|
String[] |
getHeader()
If reading a header was specified, then it can be retrieved via this
method.
|
Iterator<String[]> |
iterator() |
String[] |
record()
Retrieve the next record in the CSV file.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic RFC4180CSVParser(Reader reader) throws IOException
reader - reader to read.IOException - on IO exceptionpublic RFC4180CSVParser(boolean hasHeader,
Reader reader)
throws IOException
hasHeader - true if there is a header to readreader - readerIOException - on IO exceptionpublic RFC4180CSVParser(char sep,
boolean hasHeader,
Reader reader)
throws IOException
sep - character separatorhasHeader - true if there is a header to readreader - readerIOException - on IO exceptionpublic String[] getHeader()
public void close()
close in interface Closeableclose in interface AutoCloseablepublic String[] record() throws IOException
IOException - on exceptionCopyright © 2020. All rights reserved.