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

ListgetStringList(String csv)
get String List
String[] eqArr = csv.split(",");
List<String> subStringList = new ArrayList<String>();
for (int i = 0; i < eqArr.length; i++) {
    String eqString = eqArr[i].trim();
    subStringList.add(eqString);
return subStringList;
ListgetStringListFromCsv(String tags)
get String List From Csv
return Arrays.asList(tags.split("\\s*,\\s*"));
voidgetVendorIdsAndNames(String vendorCsv, List vendorNames, List vendorIDs)
get Vendor Ids And Names
if (vendorCsv != null && vendorCsv.length() > 0) {
    vendorNames.add(vendorCsv);
    if (mapVendorNameToVendorId != null && mapVendorNameToVendorId.size() > 0) {
        vendorIDs.add(mapVendorNameToVendorId.get(vendorCsv));
StringlistToCsv(List list)
Converts a List of objects to a comma separated string of the objects' string representations in the order given by the List's iterator.
StringBuffer sb = new StringBuffer();
for (Iterator<?> iter = list.iterator(); iter.hasNext();) {
    sb.append(iter.next().toString());
    if (iter.hasNext()) {
        sb.append(',');
return sb.toString();
...
StringlistToCsv(List listOfStrings, char separator)
To convert list to separated value
StringBuilder sb = new StringBuilder();
for (int i = 0; i < listOfStrings.size() - 1; i++) {
    sb.append(listOfStrings.get(i));
    sb.append(separator);
if (listOfStrings.size() > 0) {
    sb.append(listOfStrings.get(listOfStrings.size() - 1));
return sb.toString();
StringlistToCsv(List strs)
list To Csv
return doListToCsv(strs);
StringListtoCSV(List thelist, String sep)
Listto CSV
if (thelist.isEmpty())
    return "";
StringBuilder sb = new StringBuilder();
for (Object obj : thelist) {
    sb.append(obj.toString());
    sb.append(sep);
return sb.substring(0, sb.toString().length() - sep.length());
...
StringlistToCSVString(List list)
Returns a CSV list from the elements of a List
if (list == null) {
    return "";
String result = "";
for (int i = 0; i < list.size(); i++) {
    result += (i > 0 ? "," : "") + list.get(i).toString();
return result;
...
StringlistToCsvTags(List tagsList)
Converts a List of tags to a comma separated list
String tags = "";
if (tagsList.size() > 0) {
    for (int i = 0; i < tagsList.size(); i++) {
        tags += tagsList.get(i);
        if (i != tagsList.size() - 1) {
            tags += ",";
return tags;
ListparseCSVList(String csv)
parse CSV List
if (csv == null) {
    return null;
if (csv.isEmpty()) {
    return Collections.emptyList();
return new ArrayList<String>(Arrays.asList(csv.split(",")));