Here you can find the source of copyOfRange(final byte[] original, final int from, final int to)
public static byte[] copyOfRange(final byte[] original, final int from, final int to)
//package com.java2s; public class Main { public static byte[] copyOfRange(final byte[] original, final int from, final int to) { final int newLength = to - from; if (newLength < 0) { throw new IllegalArgumentException(from + " > " + to); }//w w w .j ava2s . c o m final byte[] copy = new byte[newLength]; System.arraycopy(original, from, copy, 0, Math.min(original.length - from, newLength)); return copy; } }