Java Utililty Methods Array Merge

List of utility methods to do Array Merge

Description

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

Method

byte[]mergeArrays(byte[] buf1, byte[] buf2)
Merges two byte arrays.
byte[] resBuf = new byte[buf1.length + buf2.length];
System.arraycopy(buf1, 0, resBuf, 0, buf1.length);
System.arraycopy(buf2, 0, resBuf, buf1.length, buf2.length);
return resBuf;
byte[]mergeArrays(byte[] first, byte[]... more)
Merges two or more byte arrays into one.
int totalLength = first.length;
for (byte[] ar : more) {
    totalLength += ar.length;
byte[] res = Arrays.copyOf(first, totalLength);
int offset = first.length;
for (byte[] ar : more) {
    System.arraycopy(ar, 0, res, offset, ar.length);
...
byte[]mergeArrays(final byte[] buf1, final byte[] buf2)
merge Arrays
final byte[] resBuf = new byte[buf1.length + buf2.length];
System.arraycopy(buf1, 0, resBuf, 0, buf1.length);
System.arraycopy(buf2, 0, resBuf, buf1.length, buf2.length);
return resBuf;
Object[]mergeArrays(final Object[] a1, final Object[] a2, final Object[] merge)
merge Arrays
System.arraycopy(a1, 0, merge, 0, a1.length);
System.arraycopy(a2, 0, merge, a1.length, a2.length);
return merge;
int[]mergeArrays(int[] theArrayA, int[] theArrayB)
merge Arrays
int[] myCopyArray = new int[theArrayA.length + theArrayB.length];
System.arraycopy(theArrayA, 0, myCopyArray, 0, theArrayA.length);
System.arraycopy(theArrayB, 0, myCopyArray, theArrayA.length, theArrayB.length);
return myCopyArray;
long[]mergeArrays(long[] alldistances, long[] currentUserDistances)
merge Arrays
long[] finalArray = new long[alldistances.length + currentUserDistances.length];
for (int i = 0; i < alldistances.length; i++) {
    finalArray[i] = alldistances[i];
for (int i = alldistances.length; i < finalArray.length; i++) {
    finalArray[i] = currentUserDistances[i - alldistances.length];
return finalArray;
...
voidmergeArrays(Object[] arr1, Object[] arr2, Object[] destinationArray)
Merges arrays into one larger array
System.arraycopy(arr1, 0, destinationArray, 0, arr1.length);
System.arraycopy(arr2, 0, destinationArray, arr1.length, arr2.length);
Object[]mergeArrays(Object[] first, Object[] second)
Merges two Array to one.
if (first != null && second == null)
    return first;
if (first == null && second != null)
    return second;
if (first != null && second != null) {
    int size = first.length + second.length;
    Object[] newObjectArray = new Object[size];
    for (int i = 0; i < first.length; i++)
...
String[]mergeArrays(String[] a, String[] b)
Create the union of two string arrays.
if (a == null) {
    return b;
if (b == null) {
    return a;
Vector v = new Vector();
for (int i = 0; i < a.length; i++) {
...
String[]mergeArrays(String[] a1, String[] a2)
merge Arrays
if (a1 == null)
    return a2;
if (a2 == null)
    return a1;
List<String> list = new ArrayList<String>(a1.length + a2.length);
for (String s : a1) {
    list.add(s);
for (String s : a2) {
    if (!list.contains(s))
        list.add(s);
return list.toArray(new String[list.size()]);