Android Utililty Methods String Array Join

List of utility methods to do String Array Join

Description

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

Method

Stringjoin(String[] parts, String delimiter)
Join a string array into a single string.
StringBuilder builder = new StringBuilder();
for (String s : parts) {
    builder.append(s).append(delimiter);
if (builder.length() > 0) {
    return builder.substring(0,
            builder.length() - delimiter.length());
return EMPTY;
Stringjoin(String delimiter, Object... chunks)
Efficiently combines the string representations of the specified objects, delimiting each chunk with the specified delimiter.
int nChunks = chunks.length;
int delimLength = delimiter == null ? 0 : delimiter.length();
int estimate = delimLength * (nChunks - 1);
for (Object chunk : chunks) {
    if (chunk != null) {
        estimate += chunk instanceof CharSequence ? ((CharSequence) chunk)
                .length() : 10; 
StringBuilder sb = new StringBuilder(estimate);
for (int i = 0; i < nChunks; i++) {
    Object chunk = chunks[i];
    if (chunk != null) {
        String string = chunk.toString();
        if (string != null && string.length() > 0) {
            sb.append(string);
            if ((i + 1) < nChunks && delimiter != null) {
                sb.append(delimiter);
return sb.toString();
Stringjoin(String separator, Object... texts)
join
StringBuilder result = new StringBuilder();
boolean isFirst = true;
for (Object text : texts) {
    if (isFirst) {
        result.append(separator);
        isFirst = false;
    result.append(text);
...
Stringjoin(String[] track)
join
StringBuilder buf = new StringBuilder(11 * track.length);
for (String str : track) {
    if (0 != buf.length()) {
        buf.append(",");
    buf.append(str);
return buf.toString();
...
Stringjoin(String delimiter, String[] array)
join
StringBuilder stringBuilder = new StringBuilder();
int aLen = array != null ? array.length : -1;
if (array != null && aLen > 1) {
    stringBuilder.append(array[0]).append(delimiter);
    for (int i = 1; i < aLen - 1; i++) {
        stringBuilder.append(array[i]).append(delimiter);
    return stringBuilder.append(array[aLen - 1]).toString();
...
Stringjoin(String[] strArray, String separator)
join
StringBuilder sb = new StringBuilder();
if (strArray != null) {
    boolean isFirst = true;
    for (int i = 0; i < strArray.length; i++) {
        if (isFirst) {
            isFirst = false;
        } else {
            sb.append(separator);
...
Stringjoin(String[] array, String separator)
join
return join(array, separator, false);
StringarrayToStr(String[] array)
Convert array of Strings to String using default delimiter (",")
return arrayToStr(array, DEFAULT_DELIM);
StringarrayToStr(String[] array, String delim)
Convert array of Strings to String
if (array == null) {
    return null;
if (array.length == 0) {
    return "";
StringBuilder builder = new StringBuilder();
for (int i = 0; i < array.length; i++) {
...
Stringimplode(String[] array)
implode
if (array != null && array.length > 0) {
    StringBuilder sb = new StringBuilder();
    for (String string : array) {
        sb.append(string);
    return sb.toString();
return "";
...