Java Array Merge merge(byte[] src, byte[] src2, int start, int length)

Here you can find the source of merge(byte[] src, byte[] src2, int start, int length)

Description

merge

License

Apache License

Declaration

public static byte[] merge(byte[] src, byte[] src2, int start, int length) 

Method Source Code

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

public class Main {

    public static byte[] merge(byte[] src, byte[] src2, int start, int length) {
        byte[] dest = new byte[src.length + length];
        System.arraycopy(src, 0, dest, 0, src.length);
        System.arraycopy(src2, start, dest, src.length, length);
        return dest;
    }//from   w  ww  .j  ava2s. c  om

    public static byte[] merge(byte[]... src) {
        if (src == null || src.length == 0) {
            return null;
        }
        int len = src.length;
        if (len > 1) {
            int length = 0;
            for (int i = 0; i < len; i++) {
                length += src[i].length;
            }
            byte[] dest = new byte[length];
            length = 0;
            for (int i = 0; i < len; i++) {
                byte[] sbyte = src[i];
                System.arraycopy(sbyte, 0, dest, length, sbyte.length);
                length += sbyte.length;
            }
            return dest;
        }
        return src[0];
    }
}

Related

  1. concat(double[] merged, double[] is)
  2. merge( final Item[] values, final Item[] auxiliary, final int first, final int middle, final int last)
  3. merge(byte[] a, byte[] b)
  4. merge(byte[] array1, byte[] array2)
  5. merge(byte[] signature, byte[] message)
  6. merge(byte[] src1, byte[] src2)
  7. merge(byte[]... arrays)
  8. merge(byte[]... bytes)
  9. merge(double[] a, int[] b, int p, int q, int r)