Java tutorial
//package com.java2s; import java.io.ByteArrayOutputStream; import java.util.ArrayList; import java.util.List; public class Main { public static List<ByteArrayOutputStream> cutby(int value, byte[] content) { List<ByteArrayOutputStream> bytes = new ArrayList<ByteArrayOutputStream>(); ByteArrayOutputStream out = new ByteArrayOutputStream(); boolean preisSame = false; // if (content.length > 0) { for (int i = 0; i < content.length; i++) { if (content[i] != value) { out.write(content[i]); preisSame = false; } else if (!preisSame) { if (out.size() > 0) { bytes.add(out); out = new ByteArrayOutputStream(); } preisSame = true; } } } if (out.size() > 0) { bytes.add(out); } return bytes; } }