Java Collection Convert toDelimitedList(Collection values, String delimiter)

Here you can find the source of toDelimitedList(Collection values, String delimiter)

Description

to Delimited List

License

Open Source License

Declaration

public static <T> String toDelimitedList(Collection<T> values, String delimiter) 

Method Source Code


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

import java.util.Collection;

public class Main {
    public static <T> String toDelimitedList(Collection<T> values, String delimiter) {
        StringBuilder sb = new StringBuilder();
        boolean first = true;
        for (T value : values) {
            if (first) {
                first = false;/*from  w  w  w .java2 s  .  c  o  m*/
            } else {
                sb.append(delimiter);
            }
            sb.append(value);
        }
        return sb.toString();
    }
}

Related

  1. toCommaSeparatedValues(Collection list)
  2. toCommaSepared(Collection aListOfString)
  3. toCommaString(Collection c)
  4. toCsvString(Collection collection)
  5. toCSVString(Collection theCollection, String theSeparator)
  6. toDelimitedString(Collection c, String delimiter)
  7. toDelimitedString(Collection coll, String delim)
  8. toDelimitedString(final Collection coll, final String delim)
  9. toDoubles(Collection numbers)