Java Utililty Methods Collection Convert

List of utility methods to do Collection Convert

Description

The list of methods to do Collection Convert are organized into topic(s).

Method

StringtoCommaSep(Collection strings)
to Comma Sep
if (strings.isEmpty()) {
    return "&bNone";
StringBuilder sb = new StringBuilder();
strings.forEach(s -> sb.append("&3").append(s).append("&7, "));
return sb.delete(sb.length() - 2, sb.length()).toString();
StringtoCommaSeparatedString(final Collection items)
Returns string containing item names, each separated from other with comma and space.
String result = "";
for (final Iterator<? extends Object> iter = items.iterator(); iter.hasNext();) {
    result += iter.next();
    if (iter.hasNext()) {
        result += COMMA_SPACE_SEPARATOR;
return result;
...
StringtoCommaSeparatedValues(Collection list)
to Comma Separated Values
StringBuilder csv = new StringBuilder();
if (list != null) {
    Object[] array = list.toArray(new Object[list.size()]);
    for (int i = 0; i < list.size(); i++) {
        if (i > 0) {
            csv.append(",");
        if (array[i] != null) {
...
StringtoCommaSepared(Collection aListOfString)
to Comma Separed
String res = "";
if (isNotEmpty(aListOfString)) {
    res = aListOfString.toString();
return res;
StringtoCommaString(Collection c)
to Comma String
String commaStr = "";
for (String str : c) {
    commaStr = commaStr + str + ",";
commaStr = commaStr.substring(0, commaStr.length() - 1);
return commaStr;
StringtoCsvString(Collection collection)
Constructs a single String by iterating over the elements in the collection parameter, calling toString() on each method.
return toXsvString(collection, ", ");
StringtoCSVString(Collection theCollection, String theSeparator)
Returns a csv string of the given values.
if ((theCollection == null) || (theSeparator == null)) {
    return "";
StringBuffer sbReturn = new StringBuffer();
boolean isFurther = false;
for (T theElement : theCollection) {
    if (isFurther) {
        sbReturn.append(theSeparator);
...
StringtoDelimitedList(Collection values, String delimiter)
to Delimited List
StringBuilder sb = new StringBuilder();
boolean first = true;
for (T value : values) {
    if (first) {
        first = false;
    } else {
        sb.append(delimiter);
    sb.append(value);
return sb.toString();
StringtoDelimitedString(Collection c, String delimiter)
to Delimited String
if (c.isEmpty()) {
    return "";
StringBuffer result = new StringBuffer();
for (Iterator i = c.iterator(); i.hasNext();) {
    Object o = i.next();
    result.append(delimiter + ((o == null) ? "" : o.toString()));
return result.substring(delimiter.length());
StringtoDelimitedString(Collection coll, String delim)
to Delimited String
return toDelimitedString(coll, delim, "", "");