Java Collection to String convertCollectionToString(Collection coll, String delimiter)

Here you can find the source of convertCollectionToString(Collection coll, String delimiter)

Description

convert Collection To String

License

Open Source License

Declaration

public static String convertCollectionToString(Collection<String> coll,
            String delimiter) 

Method Source Code

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

import java.util.Collection;

public class Main {
    public static String convertCollectionToString(Collection<String> coll,
            String delimiter) {//from w  ww.  j  a  v a  2 s  . c  om
        if (coll == null) {
            return null;
        }

        StringBuilder sb = new StringBuilder();
        for (String value : coll) {
            sb.append(value);
            sb.append(delimiter);
        }

        if (sb.length() > 0) {
            sb.delete(sb.length() - delimiter.length(), sb.length());
        }
        return sb.toString();

    }
}

Related

  1. collectionToStringList(Collection list, String delimiter)
  2. commaSeparatedList(Collection objects)
  3. commaSeparatedString(List list, boolean quoteStrings)
  4. convertCollectionToCommaDelimitedString(Collection collection)
  5. convertCollectionToString( Collection strings, String separator)
  6. convertEnumsToString(Collection> enums)
  7. convertListToString(Collection list)
  8. convertString(Collection strings)
  9. convertStringCollectionToString(Collection collectionString, String delemeter)