public class CSVReader extends Object implements Closeable
Modifier and Type | Field and Description |
---|---|
static char |
DEFAULT_ESCAPE_CHARACTER |
static char |
DEFAULT_QUOTE_CHARACTER |
static char |
DEFAULT_SEPARATOR |
Constructor and Description |
---|
CSVReader(Reader r)
Constructs CSVReader using a comma for the separator.
|
CSVReader(Reader r,
char separator)
Constructs CSVReader with supplied separator.
|
CSVReader(Reader r,
char separator,
char quotechar)
Constructs CSVReader with supplied separator and quote char.
|
CSVReader(Reader r,
char separator,
char quotechar,
char escape)
Constructs CSVReader with supplied separator and quote char.
|
CSVReader(Reader r,
char separator,
char quotechar,
char escape,
boolean skipSpaces)
Constructs CSVReader with supplied separator and quote char.
|
CSVReader(Reader reader,
CsvConfiguration csvConfig) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underlying reader.
|
int |
getRow() |
List<String[]> |
readAll()
Reads the entire file into a List with each element being a String[] of
tokens.
|
String[] |
readNext()
Reads the next line from the buffer and converts to a string array.
|
void |
setCommentChar(char c) |
public static char DEFAULT_SEPARATOR
public static char DEFAULT_QUOTE_CHARACTER
public static char DEFAULT_ESCAPE_CHARACTER
public CSVReader(Reader r)
r
- the reader to an underlying CSV source.public CSVReader(Reader r, char separator)
r
- the reader to an underlying CSV source.separator
- the delimiter to use for separating entries.public CSVReader(Reader r, char separator, char quotechar)
r
- the reader to an underlying CSV source.separator
- the delimiter to use for separating entriesquotechar
- the character to use for quoted elementspublic CSVReader(Reader r, char separator, char quotechar, char escape)
r
- the reader to an underlying CSV source.separator
- the delimiter to use for separating entriesquotechar
- the character to use for quoted elementsescape
- the character to use for escaping a separator or quotepublic CSVReader(Reader r, char separator, char quotechar, char escape, boolean skipSpaces)
r
- the reader to an underlying CSV source.separator
- the delimiter to use for separating entriesquotechar
- the character to use for quoted elementsescape
- the character to use for escaping a separator or quoteskipSpaces
- whether should spaces in front of quoted columns be skipped or taken as an errorpublic CSVReader(Reader reader, CsvConfiguration csvConfig)
public List<String[]> readAll() throws IOException
IOException
- if bad things happen during the readpublic String[] readNext() throws IOException
IOException
- if bad things happen during the readpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
- if the close failspublic void setCommentChar(char c)
public int getRow()
Copyright © 2014. All rights reserved.