public class CSVParser extends Object
The CSVParser
allows importing data into applications quickly from a CSV source. CSV
is a file format
that is supported by all spreadsheets and most databases for data exchange.
The sample below lists a simple hardcoded CSV within the table:
Constructor and Description |
---|
CSVParser()
Initializes a parser with the default comma (',') separator char
|
CSVParser(char separatorChar)
Allows creating a parser with a custom separator char
|
Modifier and Type | Method and Description |
---|---|
String[][] |
parse(InputStream r)
Parses input from the given stream and returns the tokens broken into rows and columns
|
String[][] |
parse(InputStream r,
String encoding)
Parses input from the given stream and returns the tokens broken into rows and columns
|
String[][] |
parse(Reader r)
Parses input from the given reader and returns the tokens broken into rows and columns
|
public CSVParser()
public CSVParser(char separatorChar)
separatorChar
- custom separator character such as semi-colon (';') etc.public String[][] parse(InputStream r) throws IOException
r
- the input streamIOException
public String[][] parse(InputStream r, String encoding) throws IOException
r
- the input streamencoding
- the encoding of the streamIOException
public String[][] parse(Reader r) throws IOException
r
- the reader streamIOException