Java Utililty Methods CSV File Parse

List of utility methods to do CSV File Parse

Description

The list of methods to do CSV File Parse are organized into topic(s).

Method

ListparseCSVIntegers(String csv)
Parses a CSV string into a list of integers
String[] vals = csv.split(",");
List<Integer> ints = new ArrayList<Integer>();
for (String val : vals) {
    String v = val.trim();
    if (v.length() > 0) {
        Integer n = Integer.parseInt(v);
        if (n != null)
            ints.add(n);
...
String[]parseCsvLine(final String line)
parse Csv Line
return parseCsvLine(',', '"', line);
ArrayListparseCSVLine(String CSVLine, char delimChar, char quotChar)
parse CSV Line
char itr;
boolean inQuotedValue = false;
String buffer = "";
ArrayList<String> parsedLine = new ArrayList<String>();
for (int i = 0; i < CSVLine.length(); i++) {
    itr = CSVLine.charAt(i);
    if (itr == delimChar) {
        if (!inQuotedValue) {
...
ListparseCsvRecord(String record, char csvSeparator)
CSV record parser.
boolean quoted = false;
StringBuilder fieldBuilder = new StringBuilder();
List<String> fields = new ArrayList<String>();
for (int i = 0; i < record.length(); i++) {
    char c = record.charAt(i);
    fieldBuilder.append(c);
    if (c == '"') {
        quoted = !quoted; 
...
ListparseCsvString(String toParse)
Parse comma separated string into list of tokens.
if (toParse == null || toParse.length() == 0) {
    return null;
String[] t = toParse.split(",");
if (t.length == 0) {
    return null;
List<String> ret = new ArrayList<String>();
...
ArrayListparseExcelCSVLine(String line)
Reads a line of text in the Excel CSV format
Each field is separated by a comma, except some fields have quotes around them because the field has commas or spaces.
TODO: Test to see how quotes within fields are treated
if (line == null) {
    return null;
ArrayList thisRecord = new ArrayList();
boolean quote = false;
boolean completeField = false;
StringBuffer value = new StringBuffer("");
for (int i = 0; i < line.length(); i++) {
...
ArrayListparseLine(String csvLine)
parse Line
return parseLine(csvLine, DEFAULT_SEPARATOR, DEFAULT_QUOTE);