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

ListparseCsvList(String csvList)
Parse a comma separated string into a sequence of strings.
List<String> list = new ArrayList<String>();
if (csvList == null || csvList.isEmpty())
    return list;
String[] split = csvList.split("\\s*,\\s*");
for (String v : split) {
    if (!v.equals(""))
        list.add(v);
return list;
ListsanitizeListForCsv(List strList)
Sanitizes the list of strings for comma-separated values (CSV) file output.
We follow the definition described by RFC 4180:
http://tools.ietf.org/html/rfc4180
List<String> sanitizedStrList = new ArrayList<String>();
Iterator<String> itr = strList.iterator();
while (itr.hasNext()) {
    sanitizedStrList.add(sanitizeForCsv(itr.next()));
return sanitizedStrList;
StringtoCsv(final List list)
Convert List of strins to csv
return toString(list, ';');
StringtoCsv(List list)
to Csv
String csv = "";
Integer size = list.size();
for (int i = 0; i < size; i++) {
    csv += list.get(i).toString() + ",";
return csv.substring(0, csv.length() - 1);
StringtoCsv(List list)
Convert the list of strings to a comma separated string
String res = "";
Iterator<String> it = list.iterator();
while (it.hasNext()) {
    res += it.next();
    if (it.hasNext())
        res += ", ";
return res;
...
StringtoCsv(List strs)
to Csv
StringBuilder s = new StringBuilder();
for (int i = 0; i < strs.size() - 1; i++) {
    s.append(strs + ", ");
s.append(strs.get(strs.size() - 1));
return (s.toString());
StringtoCSV(List list)
to CSV
StringBuilder sb = new StringBuilder();
for (int i = 0; i < list.size(); i++) {
    if (i != 0) {
        sb.append(COMMA);
    sb.append(list.get(i));
return sb.toString();
...
StringtoCSV(Set list)
to CSV
return _toCSV(list);
StringtoCSVLine(String[] strArray)
to CSV Line
if (strArray == null) {
    return "";
StringBuffer cvsLine = new StringBuffer();
for (int idx = 0; idx < strArray.length; idx++) {
    String item = addQuote(strArray[idx]);
    cvsLine.append(item);
    if (strArray.length - 1 != idx) {
...
StringtoCSVString(List list, boolean quote)
to CSV String
List<String> newList = new ArrayList<String>();
for (String value : list) {
    if (quote == true) {
        newList.add(quote(value));
    } else {
        newList.add(value);
if (newList != null && newList.size() > 0) {
    String values = newList.toString();
    values = values.substring(1, values.length() - 1);
    return values;
return null;