Java Utililty Methods Comma Separated List

List of utility methods to do Comma Separated List

Description

The list of methods to do Comma Separated List are organized into topic(s).

Method

StringtoCommaDelimited(List values)
Returns the comma-delimited String containing the specified values.
StringBuilder buffer = new StringBuilder();
for (String value : values) {
    if (buffer.length() > 0) {
        buffer.append(",");
    buffer.append(value);
return buffer.toString();
...
StringtoCommaList(Collection items)
to Comma List
if (items == null || items.size() == 0)
    return (null);
String itemList = "";
Iterator<?> it = items.iterator();
while (it.hasNext()) {
    String item = it.next().toString();
    itemList += item + ",";
itemList = itemList.substring(0, itemList.length() - 1);
return (itemList);
StringtoCommaSeparated(List list)
to Comma Separated
if (list != null) {
    StringBuffer buff = new StringBuffer();
    boolean comma = false;
    for (String item : list) {
        if (comma) {
            buff.append(',');
        comma = true;
...
StringtoCommaSeparated(List list)
to Comma Separated
StringBuilder sb = new StringBuilder();
for (String property : list) {
    sb.append(property).append(",");
sb.deleteCharAt(sb.length() - 1);
return sb.toString();
StringtoCommaSeparatedString(List list)
to Comma Separated String
return toString(list, ", ");
ListtoList(final String commaSeparatedString)
to List
List<String> list = new ArrayList<>();
if (commaSeparatedString == null || commaSeparatedString.trim().length() == 0) {
    return list;
String[] values = commaSeparatedString.split(",");
for (String value : values) {
    list.add(value.trim());
return list;
ListtoListDelimitedByComma(String s)
Turn a long string into a list split by our delimeter
if (s == null)
    return Collections.EMPTY_LIST;
List results = new ArrayList();
String[] terms = s.split(DELIMETER);
for (int i = 0; i < terms.length; i++) {
    String term = terms[i].trim();
    if (term.length() > 0) {
        results.add(term);
...
ListtoListOfNonEmptyStringsDelimitedByCommaOrSemicolon(String s)
to List Of Non Empty Strings Delimited By Comma Or Semicolon
if (s == null)
    return Collections.EMPTY_LIST;
List results = new ArrayList();
String[] terms = s.split(SEPARATOR);
for (int i = 0; i < terms.length; i++) {
    String term = terms[i].trim();
    if (term.length() > 0) {
        results.add(term);
...
ListtoListOfStringsDelimitedByCommaOrSemicolon(String s)
This version returns the complete list, including empty string, if such entry is empty
if (s == null) {
    return Collections.EMPTY_LIST;
List results = new ArrayList();
String[] terms = s.split(SEPARATOR);
for (int i = 0; i < terms.length; i++) {
    String term = terms[i].trim();
    results.add(term);
...