public class CSVReader extends Object
Reader classes and in particular
is similar to the LineNumberReader in terms of its API.| Constructor and Description |
|---|
CSVReader(Reader reader)
Constructs a CSV reader with the default options.
|
CSVReader(Reader reader,
char comment)
Constructs a CSV reader with the specified options.
|
CSVReader(Reader reader,
char delimiter,
char comment)
Constructs a CSV reader with the specified options.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the input
|
long |
countFields()
Reads and parses the next CSV line from the input.
|
String |
getCurrentLine() |
int |
getLineNumber()
Returns the current line number.
|
String |
readCSVLine()
Read a line of CSV text.
|
String |
readJSonLine()
Reads and parses the next CSV line from the input.
|
List<String> |
readLine()
Reads and parses the next CSV line from the input.
|
List<String> |
readLine(boolean includeComment)
Reads and parses the next CSV line from the input.
|
public CSVReader(Reader reader)
reader - input to read from.public CSVReader(Reader reader, char comment)
reader - input to read from. A BufferedReader is recommended for better performance.
Note that a LineNumberReader should not be used since it will not
be able to track the line numbers correctly (newlines can be escaped in a CSV file).comment - character indicating line is a comment and should be ignoredpublic CSVReader(Reader reader, char delimiter, char comment)
reader - input to read from. A BufferedReader is recommended for better performance.
Note that a LineNumberReader should not be used since it will not
be able to track the line numbers correctly (newlines can be escaped in a CSV file).comment - character indicating line is a comment and should be ignoreddelimiter - field delimiter characterpublic int getLineNumber()
public String getCurrentLine()
public List<String> readLine() throws IOException, ParseException
null if EOF reachedIOException - if an error occurs reading the inputParseException - if an error occurs during CSV parsingpublic List<String> readLine(boolean includeComment) throws IOException, ParseException
includeComment - true to include lines starting with comment charnull if EOF reachedIOException - if an error occurs reading the inputParseException - if an error occurs during CSV parsingpublic long countFields()
throws IOException,
ParseException
IOException - if an error occurs reading the inputParseException - if an error occurs during CSV parsingpublic String readJSonLine() throws IOException, ParseException
IOException - if an error occurs reading the inputParseException - if an error occurs during CSV parsingpublic void close()
throws IOException
IOException - if an I/O error occurspublic String readCSVLine() throws IOException
IOException - if an IO error occursCopyright © 2020. All Rights Reserved.