Java Collection to String collectionToString(Collection collection, String separator)

Here you can find the source of collectionToString(Collection collection, String separator)

Description

collection To String

License

Open Source License

Declaration

public static String collectionToString(Collection<?> collection, String separator) 

Method Source Code

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

import java.util.Collection;

public class Main {
    public static String collectionToString(Collection<?> collection, String separator) {
        StringBuilder sb = new StringBuilder();
        for (Object o : collection) {
            sb.append(o.toString());//w  ww. ja v  a 2s . c om
            if (separator != null) {
                sb.append(separator);
            }
        }
        if (sb.length() >= separator.length()) {
            sb.delete(sb.length() - separator.length(), sb.length());
        }
        return sb.toString();
    }
}

Related

  1. collectionToString(Collection c)
  2. collectionToString(Collection c)
  3. collectionToString(Collection c)
  4. collectionToString(Collection c, String separator)
  5. collectionToString(Collection coll, String connectSymbol)
  6. collectionToString(Collection collection, String separator)
  7. collectionToString(Collection elements)
  8. collectionToString(Collection list)
  9. collectionToString(Collection list)