Merge byte Array into one big byte array - Android File Input Output

Android examples for File Input Output:Byte Array Convert

Description

Merge byte Array into one big byte array

Demo Code


//package com.java2s;

public class Main {

    public static byte[] byteArrayAdd(byte[]... bytes) {
        byte[] result = bytes[0];
        for (int i = 1; i < bytes.length; i++) {
            result = byteArrayAdd(result, bytes[i]);
        }/*from   ww w . j a v  a 2  s  .  c om*/
        return result;
    }

    public static byte[] byteArrayAdd(byte[] a, byte[] b) {
        byte c[] = new byte[a.length + b.length];
        int i;
        for (i = 0; i < a.length; i++) {
            c[i] = a[i];
        }
        for (int j = 0; j < b.length; j++) {
            c[i] = b[j];
            i++;
        }
        return c;
    }
}

Related Tutorials