Here you can find the source of subarray(byte[] array, int startIndexInclusive, int endIndexExclusive)
public static byte[] subarray(byte[] array, int startIndexInclusive, int endIndexExclusive)
//package com.java2s; //License from project: Open Source License public class Main { public static byte[] subarray(byte[] array, int startIndexInclusive, int endIndexExclusive) { if (array == null) { return null; }//from w w w.j a v a 2 s.c om if (startIndexInclusive < 0) { startIndexInclusive = 0; } if (endIndexExclusive > array.length) { endIndexExclusive = array.length; } int newSize = endIndexExclusive - startIndexInclusive; if (newSize <= 0) { return new byte[0]; } byte[] subarray = new byte[newSize]; System.arraycopy(array, startIndexInclusive, subarray, 0, newSize); return subarray; } }