Java Utililty Methods CSV String Split

List of utility methods to do CSV String Split

Description

The list of methods to do CSV String Split are organized into topic(s).

Method

String[]splitCSV(String str)
"splitCSV" takes the given string and produces an array containing substrings that were separated by a comma.
int k = 0, count = 0;
for (int i = 0; i < str.length(); i++) {
    if (str.charAt(i) == '"')
        count++;
if ((count % 2) != 0)
    throw new IllegalArgumentException("There must be an even number of quotes.");
ArrayList<String> newArrLst = new ArrayList<String>();
...
String[]splitCSV(String str, String delim)
Splits a string by a specified delimiter into all tokens, including empty while respecting the rules for quotes and escapes defined in RFC4180.
if (str == null || str.isEmpty())
    return new String[] { "" };
ArrayList<String> tokens = new ArrayList<String>();
int from = 0, to = 0;
int len = str.length();
while (from < len) { 
    if (str.charAt(from) == CSV_QUOTE_CHAR && str.indexOf(CSV_QUOTE_CHAR, from + 1) > 0) {
        to = str.indexOf(CSV_QUOTE_CHAR, from + 1);
...
String[]SplitCSVString(String str)
Split CSV String
if (str == null) {
    return new String[0];
int pos;
int len;
int last;
char ch;
boolean quot;
...
ListtokenizeCsv(String input)
tokenize Csv
List<String> result = new ArrayList<String>();
if (null != input && !input.isEmpty()) {
    String[] tokens = input.trim().split(COMMA);
    if (null != tokens && tokens.length > 0) {
        for (String token : tokens) {
            String sanitizedToken = token.trim();
            if (!sanitizedToken.isEmpty()) {
                result.add(sanitizedToken);
...
String[][]toTable(String csv)
Convert a string in the csv format to a string table with the format [row][column]
char escape = '\\';
char string_sep = '\'';
char column_sep = ',';
char[] data = csv.toCharArray();
String value = "";
ArrayList<String> row = new ArrayList<String>();
ArrayList<String[]> table = new ArrayList<String[]>();
boolean inLine = false;
...