Java Utililty Methods CSV String Convert

List of utility methods to do CSV String Convert

Description

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

Method

StringcsvDecodeString(String value)
Used to decode a value that was encoded with the csvEncodeString function.
return value.replaceAll("\\\\(?=,)", "");
charcsvDelimiter(String line)
csv Delimiter
int semiCount = 0, commaCount = 0;
for (int walk = 0; walk < line.length(); walk++) {
    char ch = line.charAt(walk);
    switch (ch) {
    case ';':
        semiCount++;
        break;
    case ',':
...
StringcsvEncode(int value)
Encodes the given value to a CSV acceptable value.
return csvEncode(String.valueOf(value));
StringcsvEncodeString(String value)
This function is used when you build a comma separated list of filter values where you can't use an Object [].
return value.replaceAll("(?!\\\\),", "\\\\,");
StringcsvQuote(String value)
csv Quote
return '"' + value.replaceAll("\"", "\"\"") + '"';
StringcsvString(Object[] objects)
Convert an array of objects to a CSV string
String str = objects[0].toString();
for (int i = 1; i < objects.length; i++) {
    str += "," + objects[i].toString();
return str;
Stringcsvstring(Object[] str)
Create a CSV string from an array of objects.
if (str.length > 0) {
    StringBuilder csvBuilder = new StringBuilder();
    for (Object n : str) {
        csvBuilder.append(n.toString()).append(",");
    csvBuilder.deleteCharAt(csvBuilder.length() - 1);
    return csvBuilder.toString();
} else {
...
StringcsvTitleToTag(String title, int index)
csv Title To Tag
StringBuilder tag = new StringBuilder();
for (char c : title.toCharArray()) {
    if (Character.isLetterOrDigit(c))
        tag.append(Character.toLowerCase(c));
String tagString = tag.toString();
return tagString.isEmpty() ? String.format("column%d", index) : tagString;
String[]csvToArray(String dirs)
csv To Array
return dirs != null ? dirs.split(";") : new String[0];
String[][]csvToArray(String line)
csv To Array
return csvTextToArray(line, ',');