Here you can find the source of split(byte[] input)
public static byte[][] split(byte[] input)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { public static byte[][] split(byte[] input) { ArrayList<byte[]> bytes = new ArrayList<byte[]>(); int index_cache = 0; for (int i = 0; i < input.length; i++) { if (input[i] == 0x00) { byte[] b = subarray(input, index_cache, i - 1); bytes.add(b);//from w w w . ja v a 2s.c om index_cache = i + 1; } } if (index_cache != 0) { byte[] b = subarray(input, index_cache, input.length - 1); bytes.add(b); } byte[][] output = new byte[bytes.size()][input.length]; for (int i = 0; i < bytes.size(); i++) { output[i] = bytes.get(i); } return output; } public static byte[] subarray(byte[] in, int arg1, int arg2) { byte[] out = new byte[(arg2 - arg1) + 1]; if (arg2 - arg1 > in.length) { return in; } for (int i = arg1; i <= arg2; i++) { out[i - arg1] = in[i]; } return out; } }