Java Utililty Methods Array Join

List of utility methods to do Array Join

Description

The list of methods to do Array Join are organized into topic(s).

Method

Stringjoin(String[] strings, String separator)
Join all strings into a new concatenated string.
return join(Arrays.asList(strings), separator, false, false);
Stringjoin(String[] strings, String seperator)
join
String result = "";
for (String string : strings) {
    if (result.length() > 0)
        result += seperator;
    result += string;
return result;
Stringjoin(String[] strParts, String glue)
join
StringBuilder str = new StringBuilder();
for (int i = 0; i < strParts.length; i++) {
    str.append(strParts[i]).append(glue);
if (str.length() > 0)
    str.delete(str.length() - glue.length(), str.length());
return str.toString();
Stringjoin(String[] strs)
join
StringBuilder buf = new StringBuilder();
for (int i = 0; i < strs.length; i++) {
    if (i > 0) {
        buf.append(",");
    buf.append(strs[i]);
return buf.toString();
...
Stringjoin(String[] strs, String glue, int start, int end)
join
String ret;
int i;
if (start >= strs.length)
    return null;
if (end > strs.length)
    end = strs.length;
ret = strs[start];
for (i = start + 1; i < end; i++)
...
Stringjoin(String[] tokens, String delimiter)
join
if (tokens == null) {
    return "null";
if (tokens.length == 0) {
    return "";
StringBuilder sb = new StringBuilder();
sb.append(tokens[0]);
...
Stringjoin(String[] tokens, String separator)
Join all tokens dividing by a separator
StringBuilder history = new StringBuilder();
if (tokens.length > 0) {
    history.append(tokens[0]);
for (int i = 1; i < tokens.length; i++) {
    history.append(separator).append(tokens[i]);
return history.toString();
...
Stringjoin(String[] x)
Join into string
StringBuilder sb = new StringBuilder();
for (String token : x) {
    sb.append(token).append(" ");
return sb.toString().trim();
String[]join(String[]... arrays)
join
int size = 0;
for (String[] array : arrays) {
    size += array.length;
java.util.List<String> list = new java.util.ArrayList<String>(size);
for (String[] array : arrays) {
    list.addAll(java.util.Arrays.asList(array));
return list.toArray(new String[size]);
String[]join(String[]... values)
join
List<String> list = new ArrayList<String>();
for (String[] strings : values)
    Collections.addAll(list, strings);
return list.toArray(new String[list.size()]);