List of utility methods to do String Join
String | join(String delimiter, T... array) join return join(delimiter, Arrays.asList(array));
|
String | join(String glue, Iterable join StringBuilder ret = new StringBuilder(); boolean first = true; for (String item : items) { if (first) { first = false; } else { ret.append(glue); ret.append(item); return ret.toString(); |
String | join(String glue, String... str) Combine strings with a common string if (str.length > 0) { StringBuilder sb = new StringBuilder(str[0]); for (int i = 1; i < str.length; i++) sb.append(glue).append(str[i]); return sb.toString(); } else return ""; |
String | join(String joiner, String... toJoin) join return join(joiner, Arrays.asList(toJoin), 0);
|
String | join(String s, Object... objects) join if (objects.length == 0) { return ""; StringBuilder sb = new StringBuilder(objects[0].toString()); for (int i = 1; i < objects.length; i++) { sb.append(s).append(objects[i]); return sb.toString(); ... |
String | join(String sep, Object... pieces) Turns a sequence of objects into a string, delimited by sep . if ((pieces.length == 1) && (pieces[0] instanceof Collection)) { return internalJoin(sep, (Collection<Object>) pieces[0]); } else { return internalJoin(sep, Arrays.asList(pieces)); |
String | join(String separator, CharSequence... elements) join StringBuilder builder = new StringBuilder(); for (int i = 0; i < elements.length; i++) { builder.append(elements[i]); if (i < elements.length - 1) { builder.append(separator); return builder.toString(); ... |
String | join(String separator, Collection Joins a number of strings together to form one long string, with the optional separator inserted between each of them.
StringBuilder builder = new StringBuilder(); for (String string : strings) { if (builder.length() > 0 && separator != null) builder.append(separator); builder.append(string); return builder.toString(); |
String | join(String separator, List> objects) join StringBuilder builder = new StringBuilder(); for (int i = 0; i < objects.size(); i++) { builder.append(objects.get(i)); if (i != objects.size() - 1) builder.append(separator); return builder.toString(); |
String | join(String separator, Object... objects) join StringBuilder sb = new StringBuilder(); for (Object o : objects) { sb.append(o.toString()).append(separator); return sb.toString().trim(); |