List of utility methods to do List to String
String | listToString(List list) converts a list to a string taking every element and separating them with a , comma. StringBuffer result = new StringBuffer(); for (int i = 0; i < list.size(); i++) { result.append(", " + list.get(i)); return result.substring(2); |
String | listToString(List list, char sep) list To String StringBuffer buffer = new StringBuffer(); if (list != null) { for (int i = 0; i < list.size(); i++) { if (buffer.length() > 0) { buffer.append(sep); buffer.append(list.get(i)); return buffer.toString(); |
String | listToString(List list, String delim) Print out a List in a user-friendly string format. if (list == null) { return "NULL"; Iterator i = list.iterator(); return iteratorToString(i, delim, null); |
String | listToString(List list, String glue) list To String String result = ""; boolean first = true; for (Object item : list) { if (!first) result += glue; result += item.toString(); first = false; return result; |
String | listToString(List list, String prefix, String suffix, String separator) list To String if (list == null) return null; return iteratorToString(list.iterator(), prefix, suffix, separator); |
String | listToString(List extends Object> list) list To String StringBuffer sb = new StringBuffer(); sb.append("["); boolean first = true; for (Object o : list) { if (first) first = false; else sb.append(", "); ... |
String | listToString(List extends Object> list) list To String if (null == list) return ""; if (list.isEmpty()) return "[]"; StringBuilder sb = new StringBuilder("["); for (int i = 0; i < list.size(); i++) { sb.append(list.get(i)); if (i != (list.size() - 1)) { ... |
String | listToString(List extends Object> list, String delim) Concatenate a list of Strings into a single String. StringBuilder buf = new StringBuilder(); Iterator<?> it = list.iterator(); while (it.hasNext()) { buf.append(String.valueOf(it.next())); if (it.hasNext()) { buf.append(delim); return buf.toString(); |
String | listToString(List extends Object> list, String header, String separator, String footer) list To String String delim = ""; StringBuilder sb = new StringBuilder(header); for (int i = 0; i < list.size(); i++) { sb.append(delim).append("" + list.get(i)); delim = separator; return sb.append(footer).toString(); |
String | ListToString(List extends Object> lista) List To String if (lista != null) return lista.toString().replaceAll("\\[", "").replaceAll("\\]", ""); else return ""; |