Here you can find the source of copyOfRange(byte[] original, int from, int to)
public static byte[] copyOfRange(byte[] original, int from, int to)
//package com.java2s; //License from project: Apache License public class Main { public static byte[] copyOfRange(byte[] original, int from, int to) { if (from >= original.length || to > original.length || to <= from) { return null; }/* ww w. j av a 2 s .c o m*/ int newLength = to - from; byte[] copy = new byte[newLength]; System.arraycopy(original, from, copy, 0, newLength); return copy; } }