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

ListcsvToList(String csv)
csv To List
List<String> list = new ArrayList<String>();
String[] splitString = csv.split(",");
for (int i = 0; i < splitString.length; i++) {
    list.add(splitString[i].trim());
return list;
ListCSVToList(String str)
Converts a CSV string to a list of strings.
List<String> list = new ArrayList<String>();
String[] valueString = str.split(",");
for (String value : valueString)
    if (!value.equals("[]"))
        list.add(value);
return list;
StringformatAsCsv(List stringList)
format As Csv
StringBuffer buffer = new StringBuffer();
for (Iterator<String> i = stringList.iterator(); i.hasNext();) {
    String string = i.next();
    buffer.append(string);
    if (i.hasNext()) {
        buffer.append(",");
return buffer.toString();
StringformatCsvRecord(List csvRecord, char csvSeparator)
CSV record formatter.
StringBuilder fields = new StringBuilder();
String separator = String.valueOf(csvSeparator);
for (Iterator<T> iter = csvRecord.iterator(); iter.hasNext();) {
    T object = iter.next();
    if (object != null) {
        String field = object.toString().replace("\"", "\"\""); 
        if (field.contains(separator) || field.contains("\"")) {
            field = "\"" + field + "\""; 
...
ArrayListgetArrayListFromCSV(String csvString)
get Array List From CSV
return helper1(csvString, CSV_SEPARATOR);
StringgetAsCsv(List tags)
get As Csv
return getAsCsv(tags.toArray(new String[tags.size()]));
StringgetCSV(List l)
Takes a list of String Objects and returns a String with the all values from the list separated by a comma
StringBuilder ret = new StringBuilder();
;
if (l != null) {
    for (int i = 0; i < l.size(); i++) {
        ret.append((String) l.get(i));
        if (i + 1 < l.size()) {
            ret.append(",");
return ret.toString();
StringgetCSVFromList(List myList)
Create a comma seperated value (CSV) string form the passed in list
String output = null;
Iterator<String> iter = myList.iterator();
while (iter.hasNext()) {
    String curVal = (String) iter.next();
    if (null == output) {
        output = curVal;
    } else {
        output = output + "," + curVal;
...
StringgetCSVFromList(List myList)
get CSV From List
String output = null;
Iterator<String> iter = myList.iterator();
while (iter.hasNext()) {
    String curVal = (String) iter.next();
    if (null == output) {
        output = curVal;
    } else {
        output = output + "," + curVal;
...
ListgetCSVList(String csvList)
get CSV List
if (csvList == null || csvList.length() == 0)
    return Collections.emptyList();
List<String> ret = new ArrayList<String>(Arrays.asList(csvList.split(",")));
Iterator<String> iter = ret.iterator();
while (iter.hasNext()) {
    final String next = iter.next();
    if (next == null || next.length() == 0) {
        iter.remove();
...