Java tutorial
//package com.java2s; public class Main { public static byte[] cutBytes(byte[] src, int begin, int end) { byte[] result = null; if (src != null && begin >= 0 && end < src.length && begin < end) { result = new byte[end - begin + 1]; System.arraycopy(src, begin, result, 0, end + 1 - begin); } return result; } }