Java Utililty Methods Collection to String

List of utility methods to do Collection to String

Description

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

Method

StringasString(Collection c, String separator)
as String
if (c == null) {
    return "";
StringBuilder result = new StringBuilder(256);
boolean needSeparator = false;
for (Object o : c) {
    if (o == null) {
        continue;
...
StringasString(Collection collection)
as String
if (isEmpty(collection)) {
    return "";
final StringBuilder asList = new StringBuilder(64);
for (String item : collection) {
    asList.append(", ").append(item);
return asList.substring(2);
...
String[]asStringArr(Collection collection)
as String Arr
String res[] = new String[collection.size()];
int i = 0;
for (Object s : collection) {
    res[i++] = String.valueOf(s);
return res;
String[]asStringArray(Collection coll)
Convert the collection to a string array.
int i = 0;
String[] strings = new String[coll.size()];
for (Object o : coll) {
    strings[i++] = o.toString();
return strings;
String[]asStringArray(Collection collection)
as String Array
String[] result = new String[collection.size()];
collection.toArray(result);
return result;
StringbuildString(Collection args, String seperator, int startingArg, int maxLength)
build String
List<String> retList = new ArrayList<String>();
String ret = "";
for (int i = startingArg; i < args.size(); i++) {
    String s = (String) args.toArray()[i];
    ret += s + seperator;
    if (ret.length() > maxLength) {
        retList.add(ret);
        ret = "";
...
StringbuildString(Collection keys)
build String
String build = keys.toString();
if (keys.size() == 1) {
    build = build.replace("" + OPEN_TABLE_SEPARATOR, "").replace("" + CLOSE_TABLE_SEPARATOR, "");
return build;
StringbuildStringFromListForNuma(Collection list)
build String From List For Numa
if (!list.isEmpty()) {
    StringBuilder sb = new StringBuilder();
    for (Integer item : list) {
        sb.append(item);
        sb.append(",");
    return sb.deleteCharAt(sb.length() - 1).toString();
return "";
StringcollectionToCommaDelimitedString(Collection items)
collection To Comma Delimited String
StringBuilder buf = new StringBuilder();
boolean first = true;
for (Object item : items) {
    if (!first) {
        buf.append(",");
    buf.append(item);
    first = false;
...
StringcollectionToCommaDelimitedString(Collection list)
Convert a List of Strings to a comma delimited String.
if (list == null || list.isEmpty()) {
    return "";
StringBuilder sb = new StringBuilder();
final Iterator<String> it = list.iterator();
while (it.hasNext()) {
    sb.append(it.next());
    if (it.hasNext()) {
...