List of utility methods to do String Array Combine
String[] | combine(final String[] left, final String[] right) combine final String[] rv = new String[left.length + right.length]; for (int pos = 0; pos < left.length; ++pos) rv[pos] = left[pos]; for (int pos = 0; pos < right.length; ++pos) rv[left.length + pos] = right[pos]; return rv; |
String | combine(String sep, String... s) combine String ret = ""; if (s.length > 0) { ret = s[0]; for (int i = 1; i < s.length; i++) { ret += sep + s[i]; return ret; ... |
String | combine(String style1, String style2) Combines multiple styles return style1 + "," + style2; |
String | combine(String... s) "a", "b", "c" -> "a b c a-b a-b-c" "a", "b", null -> "a b a-b" StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length; i++) { if (s[i] != null) { sb.append(s[i]); if (i < s.length - 1 && s[i + 1] != null) { sb.append(' '); for (int j = 1; j < s.length; j++) { if (s[j] != null) { sb.append(' '); for (int i = 0; i <= j; i++) { sb.append(s[i]); if (i < j && s[i + 1] != null) { sb.append('-'); return sb.toString(); |
String | combine(String... vals) combine StringBuilder buf = new StringBuilder(); for (String val : vals) { if (buf.length() > 0) buf.append(", "); buf.append(val); return buf.toString(); |
String[] | combine(String[] a, String[] b, String glue) Combined string elements from two arrays into a single array, gluing together elements of the same index with a delimiter string. String[] result = new String[Math.min(a.length, b.length)]; for (int i = 0; i < result.length; ++i) { result[i] = a[i] + glue + b[i]; return result; |
String[] | combine(String[] array1, String[] array2) Combine to string arrays. if (array1 == null || array1.length == 0) return array2; else if (array2 == null || array2.length == 0) return array1; String[] result = new String[array1.length + array2.length]; System.arraycopy(array1, 0, result, 0, array1.length); System.arraycopy(array2, 0, result, array1.length, array2.length); return result; ... |
String | combine(String[] strs, String delimeter) combine StringBuilder sb = new StringBuilder(strs.length * (20 + delimeter.length())); for (String str : strs) { sb.append(str); sb.append(delimeter); return sb.toString(); |
String | combine(String[] values, String delimiter) Combines the strings values in the string array into one single string, delimited by the specified delimiter. if (values == null) { throw new NullPointerException("values array is null"); if (values.length == 0) { return ""; StringBuffer result = new StringBuffer(); for (int i = 1; i < values.length; i++) { ... |
String | combine(String[] values, String regex) combine if (values == null) { return null; StringBuilder sb = new StringBuilder(); for (int i = 0; i < values.length; i++) { if (values[i] == null) { continue; sb.append(values[i]); if (i < values.length - 1) { sb.append(regex); return sb.toString(); |