Java Utililty Methods String Array Merge

List of utility methods to do String Array Merge

Description

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

Method

Stringmerge(String[] arr)
merge
if (arr.length == 0)
    return "";
StringBuilder str = new StringBuilder();
for (String s : arr)
    str.append(s).append(' ');
return str.toString().substring(0, str.length() - 1);
String[]merge(String[] mainSelector, String[] base)
merge
int count = 0;
for (String s : base) {
    int andCount = 0;
    int idx = -1;
    while ((idx = s.indexOf('&', idx + 1)) >= 0) {
        andCount++;
    count += mainSelector.length * Math.max(1, andCount);
...
Stringmerge(String[] pieces, String sep)
merge
if (pieces == null)
    return "";
StringBuilder buf = new StringBuilder();
for (int i = 0; i < pieces.length; i++) {
    if (i > 0)
        buf.append(sep);
    buf.append(pieces[i]);
return buf.toString();
Stringmerge(String[] src, String delimiter)
merge
StringBuffer newSrc = new StringBuffer();
for (int i = 0; i < src.length; i++) {
    if (i < src.length - 1) {
        newSrc.append(src[i]).append(delimiter);
    } else {
        newSrc.append(src[i]);
return newSrc.toString();
Stringmerge(String[] str, String sep)
merge
if (str == null || str.length == 0)
    return "";
StringBuilder sb = new StringBuilder();
sb.append(str[0]);
for (int i = 1; i < str.length; i++) {
    sb.append(sep);
    sb.append(str[i]);
return sb.toString();
Stringmerge(T[] arr0, String delimiter)
Merges the given Collection split into a String with the delimiter given.
StringBuffer buffer = new StringBuffer();
for (T t : arr0)
    buffer.append(t + delimiter);
return buffer.toString().substring(0, buffer.length() - delimiter.length());
StringmergeInts(int[] values, String delimiter)
merge Ints
if (values == null || values.length == 0) {
    return null;
StringBuffer merged = new StringBuffer(String.valueOf(values[0]));
for (int i = 1; i < values.length; i++) {
    merged.append(delimiter);
    merged.append(values[i]);
return merged.toString();
StringmergeJoin(String sep, String[] a1, String[] a2)
merge Join
if (a1.length != a2.length) {
    System.out.println("Unable to merge String arrays of different length!");
    return join(a1);
StringBuilder sb = new StringBuilder(a1[0]);
sb.append(sep).append(a2[0]);
for (int i = 1; i < a1.length; i++) {
    sb.append(" ").append(a1[i]).append(sep).append(a2[i]);
...
StringmergeJoin(String sep, String[] a1, String[] a2)
merge Join
if (a1.length != a2.length) {
    System.out.println("Unable to merge String arrays of different length!");
    return join(a1);
StringBuilder sb = new StringBuilder(a1[0]);
sb.append(sep).append(a2[0]);
for (int i = 1; i < a1.length; i++)
    sb.append(" ").append(a1[i]).append(sep).append(a2[i]);
...
StringmergeString(String currentValue, String newValue)
merge String
if (currentValue == null || currentValue.length() == 0)
    return newValue;
if (newValue == null || newValue.length() == 0)
    return currentValue;
if (newValue.length() > currentValue.length())
    return newValue;
return currentValue;