Java Array Merge mergeArrayObject(Object[] buf1, Object[] buf2)

Here you can find the source of mergeArrayObject(Object[] buf1, Object[] buf2)

Description

merge Array Object

License

Apache License

Declaration

public static Object[] mergeArrayObject(Object[] buf1, Object[] buf2) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static Object[] mergeArrayObject(Object[] buf1, Object[] buf2) {
        Object[] bufret = null;//from  w ww.  j  a v  a2s.  c o  m
        int len1 = 0;
        int len2 = 0;

        if (buf1 != null)
            len1 = buf1.length;
        if (buf2 != null)
            len2 = buf2.length;
        if (len1 + len2 > 0)
            bufret = new Object[len1 + len2];
        if (len1 > 0)
            System.arraycopy(buf1, 0, bufret, 0, len1);
        if (len2 > 0)
            System.arraycopy(buf2, 0, bufret, len1, len2);
        return bufret;
    }

    public static String[] mergeArrayObject(String[] buf1, String[] buf2) {
        String[] bufret = null;
        int len1 = 0;
        int len2 = 0;

        if (buf1 != null)
            len1 = buf1.length;
        if (buf2 != null)
            len2 = buf2.length;
        if (len1 + len2 > 0)
            bufret = new String[len1 + len2];
        if (len1 > 0)
            System.arraycopy(buf1, 0, bufret, 0, len1);
        if (len2 > 0)
            System.arraycopy(buf2, 0, bufret, len1, len2);
        return bufret;
    }

    public static Object[] mergeArrayObject(Object[] buf1, Object[] buf2, Object[] buf3) {
        Object[] objReturn = mergeArrayObject(buf1, buf2);
        return mergeArrayObject(objReturn, buf3);
    }
}

Related

  1. mergeArray(byte[] arr1, byte[] arr2)
  2. mergeArray(final Object[] dest, final Object[]... arrays)
  3. mergeArray(String[] a, String[] b)
  4. mergeArray(T[] objs, String concatenator)
  5. mergeArrayIntoString(final Object[] array, String middleDelimiter, String lastDelimiter)
  6. mergeArrays(byte[] buf1, byte[] buf2)
  7. mergeArrays(byte[] first, byte[]... more)
  8. mergeArrays(final byte[] buf1, final byte[] buf2)
  9. mergeArrays(final Object[] a1, final Object[] a2, final Object[] merge)