code: public static byte[] duplicateByteArray(byte[] in, int offset, int length)
      {
          if (in == null) return null;
  
          byte[] out =  new byte[length];
          System.arraycopy(in, offset, out, 0, length);
  
          return out;
      }
docs: Duplicate a piece of a byte array.