List of utility methods to do Collection to String
String | listToString(Collection Change list to string comma separated. StringBuilder buffer = new StringBuilder(); int counter = 0; for (String str : objects) { if (counter > 0) { buffer.append(","); counter++; buffer.append(str); ... |
String[] | listToStringArray(Collection list To String Array if (list == null) { return null; } else { String valueArr[] = new String[list.size()]; list.toArray(valueArr); return valueArr; |
StringBuilder | listToStringHelper(StringBuilder sb, String sep, Collection> list) list To String Helper for (Object line : list) { sb.append(line).append(sep); if (sb.length() > 0) { sb.setLength(sb.length() - sep.length()); return sb; |
String | stringify(Collection> collection) stringify StringBuilder buf = new StringBuilder(); for (Object o : collection) { if (buf.length() > 0) buf.append("\n"); buf.append(o); return buf.toString(); |
Collection | stringify(Collection Converts the given collection to a collection of strings by calling toString() on each item. return stringify(collection, true);
|
String | toStr(Collection to Str if (collection == null) return "[]"; Iterator<E> i = collection.iterator(); if (!i.hasNext()) return "[]"; StringBuilder sb = new StringBuilder(); sb.append('['); for (;;) { ... |
String[] | toStr(Collection Converts the collection into an array of strings. String[] strElements = null; if (elements != null) { strElements = new String[elements.size()]; Object[] oElements = elements.toArray(); for (int i = 0; i < oElements.length; i++) { strElements[i] = oElements[i].toString(); return strElements; |
String | toString(Collection c) Same as #toString(Collection,String) toString separated by ", ". return toString(c, ", "); |
String | toString(Collection c) to String if (c == null) return "null"; StringBuffer str = new StringBuffer(); Iterator i = c.iterator(); str.append("["); while (i.hasNext()) { Object o = i.next(); if (o instanceof byte[]) ... |
String | toString(Collection c, String start, String separator, String end) An flexible alternative for converting a Collection to a String. Iterator i = c.iterator(); StringBuilder myString = new StringBuilder(); if (start != null) { myString.append(start); boolean first = true; while (i.hasNext()) { if (!first) { ... |