Java CSV from convertStringListToCSV(List inputStringList)

Here you can find the source of convertStringListToCSV(List inputStringList)

Description

Utility to convert List of Strings to CSV string.

License

Open Source License

Parameter

Parameter Description
inputStringList Input List of strings

Return

CSV string or null if null or empty list.

Declaration

public static String convertStringListToCSV(List<String> inputStringList) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.List;

public class Main {
    /**//from w w  w  . j ava2s .co m
     * Utility to convert List of Strings to CSV string.
     *
     * @param inputStringList Input List of strings
     * @return CSV string or null if null or empty list.
     */
    public static String convertStringListToCSV(List<String> inputStringList) {
        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);
        return sb.toString();
    }
}

Related

  1. addAllFromCSV(List list, String csv)
  2. convertListToCSVString(List itemsList)
  3. convertListToCSVString(List list)
  4. convertStringListToCSV(List source)
  5. countMaxColumnSizeByArray(List csvs)
  6. csv2list(String csvString)
  7. csvList(String _text, Integer[] _idx_ret)