There is a large array with bytes:

byte[] binary = ...; 

How can I split this array into several arrays using this separator:

 byte[] split = new byte[]{0, 0x065, 4}; 

That is, you need to do the same thing as:

 String default = "abcabcabcaaaa"; String split = "b"; String[] result = default.split("b"); 

but only with bytes.

    1 answer 1

    An example from here https://stackoverflow.com/a/29084734/1828296 :

     public static List<byte[]> tokens(byte[] array, byte[] delimiter) { List<byte[]> byteArrays = new LinkedList<>(); if (delimiter.length == 0) { return byteArrays; } int begin = 0; outer: for (int i = 0; i < array.length - delimiter.length + 1; i++) { for (int j = 0; j < delimiter.length; j++) { if (array[i + j] != delimiter[j]) { continue outer; } } byteArrays.add(Arrays.copyOfRange(array, begin, i)); begin = i + delimiter.length; } byteArrays.add(Arrays.copyOfRange(array, begin, array.length)); return byteArrays; }