Java Collection to String collectionToString(Collection c)

Here you can find the source of collectionToString(Collection c)

Description

collection To String

License

Open Source License

Declaration

public static String collectionToString(Collection<?> c) 

Method Source Code


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

import java.util.Collection;
import java.util.List;

public class Main {
    public static String collectionToString(Collection<?> c) {
        return c.toString();
    }/*from  w  w  w.ja v a2s  .c o m*/

    public static String collectionToString(Collection<?> c, String delimeter) {
        StringBuilder result = new StringBuilder(c.toString().replaceAll(",", delimeter));
        result.deleteCharAt(0);
        result.deleteCharAt(result.length() - 1);
        return result.toString();
    }

    public static void collectionToString(List<String> cols, StringBuilder sql) {
        for (String col : cols) {
            sql.append(col + ",");
        }
        if (sql.length() > 1) {
            sql.deleteCharAt(sql.length() - 1);
        }
    }
}

Related

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