code: public static byte[] getBytes(ByteBuffer bytes) {
          byte[] result = new byte[bytes.remaining()];    // bytes between position and limit
          bytes.get(result);
          return result;
      }
docs: Extract the bytes in the given ByteBuffer and return it as a byte[]. CAUTION: this
  method calls ByteBuffer.get(), which <i>transfers</i> bytes from the ByteBuffer to
  the result buffer. Hence, it is "destructive" in the sense that the value cannot be
  examined again without calling ByteBuffer.rewind() or something else.
  
  @param   bytes   ByteBuffer.
  @return          Contents between 'position' and 'limit' (aka 'remaining') as a
  byte[].
  @see     #copyBytes(ByteBuffer)