public class CSVParser extends Object
Notes: Line with trailing comma will result in an empty string field
Attempts to follow this suggestion from RFC4180:
Implementors should
"be conservative in what you do, be liberal in what you accept from others" (RFC 793)
when processing CSV files.
| Constructor and Description |
|---|
CSVParser()
Constructor with default delimiter (,) and trimFields (true).
|
CSVParser(char delimiter,
boolean trimFields)
Constructs the parser with specified options
|
| Modifier and Type | Method and Description |
|---|---|
long |
countFields(String line)
Assumes this is one line of CSV text
|
String |
toJSon(String line,
long lineNumber)
Assumes this is one line of CSV text
|
List<String> |
tokenize(String line)
Assumes this is one line of CSV text
|
public CSVParser()
public CSVParser(char delimiter,
boolean trimFields)
delimiter - field separator character (e.g. comma, tab, vertical bar / pipe, space)trimFields - indicates if fields are to be trimmed or notpublic List<String> tokenize(String line) throws ParseException
line - line of text to parseParseException - if
public long countFields(String line) throws ParseException
line - line of text to parseParseException - if
public String toJSon(String line, long lineNumber) throws ParseException
line - line of text to parseParseException - if
Copyright © 2020. All Rights Reserved.