public static byte[] copyOf(byte[] arr,int offset,int newLength,int dstOffset){
  byte[] newArr=new byte[newLength];
  int srcLen=arr.length - offset;
  int dstLen=newLength - dstOffset;
  System.arraycopy(arr,offset,newArr,dstOffset,Math.min(srcLen,dstLen));
  return newArr;
}

public static byte [ ] copyOf ( byte [ ] arr , int offset , int newLength , int dstOffset ) { byte [ ] newArr = new byte [ newLength ] ; int srcLen = arr . length - offset ; int dstLen = newLength - dstOffset ; System . arraycopy ( arr , offset , newArr , dstOffset , Math . min ( srcLen , dstLen ) ) ; return newArr ; }
returns a copy of the given array of the given length starting at the given position .
