code: public final static byte[] consumeBytes(byte[] in, int numBytesMax) {
          int limit = Math.min(in.length, numBytesMax);
          byte[] out = new byte[limit];
          System.arraycopy(in, 0, out, 0, limit);
          return out;
      }
docs: Consumes bytes from an input buffer and returns them in an output buffer.
  
  @param in
  Input byte array
  @param numBytesMax
  Number of bytes max
  @return out Output byte array