Java Utililty Methods CSV from

List of utility methods to do CSV from

Description

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

Method

voidaddAllFromCSV(List list, String csv)
add All From CSV
csv = csv.trim();
if (csv.isEmpty()) {
    return;
String[] values = csv.split(",");
for (String s : values) {
    list.add(s.trim());
StringconvertListToCSVString(List itemsList)
convert List To CSV String
StringBuilder csvString = new StringBuilder();
if (itemsList != null && !itemsList.isEmpty()) {
    for (Long item : itemsList) {
        if (csvString.length() > 0) {
            csvString.append(COMMA_SEPARATOR);
            csvString.append(item.toString());
        } else {
            csvString.append(item.toString());
...
StringconvertListToCSVString(List list)
convert List To CSV String
StringBuilder result = new StringBuilder();
String comma = "";
for (String element : list) {
    result.append(comma);
    result.append(element);
    comma = ",";
return result.toString();
...
StringconvertStringListToCSV(List inputStringList)
Utility to convert List of Strings to CSV string.
if (inputStringList == null || inputStringList.size() == 0) {
    return null;
StringBuilder sb = new StringBuilder();
for (String inputString : inputStringList) {
    sb.append(inputString).append(',');
sb.deleteCharAt(sb.length() - 1);
...
StringconvertStringListToCSV(List source)
convert String List To CSV
String finalString = "";
if (source != null && !source.isEmpty()) {
    for (String s : source) {
        if (s != null) {
            finalString = finalString.isEmpty() ? finalString + getValidCsvValue(s)
                    : finalString + "," + getValidCsvValue(s);
return finalString;
intcountMaxColumnSizeByArray(List csvs)
count Max Column Size By Array
int max = 0;
for (String[] csv : csvs) {
    if (csv.length > max) {
        max = csv.length;
return max;
Listcsv2list(String csvString)
Returns a list of String literals from a comma-separated value String.
List<String> outList = new ArrayList<String>();
for (String element : csvString.split(COMMA)) {
    if (!element.isEmpty()) {
        outList.add(element);
return outList;
String[]csvList(String _text, Integer[] _idx_ret)
Kommaseparierte Werteliste in String[] umwandeln.
List<String> list = new ArrayList<String>();
int idx = 0;
boolean bCont = true;
int idxr;
do {
    idxr = _text.indexOf(',', idx);
    if (idxr == -1) {
        idxr = _text.length();
...
ListcsvTagsToList(String tags)
csv Tags To List
List<String> tagsList = new ArrayList<String>();
if (tags != null) {
    String[] tokens = tags.split(",");
    for (int i = 0; i < tokens.length; i++) {
        tagsList.add(tokens[i].trim());
return tagsList;
...
ListcsvToList(String csv)
converts a string with comma separated values to a List of Strings
if (csv == null) {
    return new ArrayList<String>();
return Arrays.asList(csv.split(CSV_SEPARATOR.toString(), -1));