List of utility methods to do Array Join
Object[] | join(Object[]... arrays) join int size = totalSize(arrays); Object[] result = new Object[size]; int i = 0; for (Object[] array : arrays) { if (array != null) { for (int j = 0; j < array.length; ++j, ++i) { result[i] = array[j]; return result; |
String | join(String delimiter, Object[] strings) join if (strings == null) return ""; int len = strings.length; String ans = ""; for (int i = 0; i < len; ++i) { if (i > 0) ans += delimiter; ans += strings[i]; ... |
String | join(String delimiter, short[] array) Joins an array of short s, separated by a delimiter.
if (array == null) { return null; StringBuilder buf = new StringBuilder(); for (int i = 0; i < array.length; i++) { buf.append(array[i]); if (i + 1 < array.length) { buf.append(delimiter); ... |
String | join(String delimiter, String[] array) join StringBuilder sb = new StringBuilder(); int counter = 0; for (String element : array) { sb.append(counter++ > 0 ? delimiter : ""); sb.append(element); return sb.toString(); |
String | join(String delimiter, String[] elements) Join an array of String elements into a single String. StringBuilder ret = new StringBuilder(); boolean firstIteration = true; for (String s : elements) { if (!firstIteration) { ret.append(delimiter); } else { firstIteration = false; ret.append(s); return ret.toString(); |
String | join(String delimiter, String[] s) join int ls = s.length; switch (ls) { case 0: return ""; case 1: return s[0]; case 2: return s[0].concat(delimiter).concat(s[1]); ... |
StringBuffer | join(String glue, String[] strings) Takes a string 'glue' and array of strings, and returns a StringBuffer containing the strings joined with the glue between each of them. return join(glue, strings, 0, strings.length - 1);
|
String | join(String glue, String[] strings) join return join(glue, asList(strings));
|
String | join(String s, String[] arr, int off, int end) join if (off < 0 || end > arr.length) { throw new IllegalArgumentException("Invalid indices"); if (end <= off) { return ""; StringBuilder sb = new StringBuilder(); for (int i = off; i < end - 1; i++) { ... |
String | join(String s[], String glue) Join the given strings with given glue StringBuilder buffer = new StringBuilder(); List list = Arrays.asList(s); Iterator iterator = list.iterator(); while (iterator.hasNext()) { buffer.append(iterator.next()); if (iterator.hasNext()) buffer.append(glue); return buffer.toString(); |