code: @Override
      public Buffer readBytes(final int length) throws IndexOutOfBoundsException, IOException {
          if (!checkReadableBytesSafe(length)) {
              final int availableBytes = getReadableBytes();
              final int read = internalReadBytes(length - availableBytes);
              if (read == -1) {
                  // end-of-file
                  return null;
              } else if (read + availableBytes < length) {
                  // do something else?
                  throw new IndexOutOfBoundsException("Not enough bytes left in the stream. Wanted " + length
                          + " but only read " + read);
              }
          }
  
          // perhaps we should create a composite buffer instead of this
          // copying???
          int index = 0;
          final byte[] buf = new byte[length];
          while (index < length) {
              final int spaceLeft = getAvailableLocalReadingSpace();
              final int readAtMost = Math.min(length - index, spaceLeft);
              final int localIndex = getLocalReaderIndex();
  
              final java.nio.ByteBuffer bb = getReadingRow();
              System.arraycopy(bb.array(), localIndex, buf, index, readAtMost);
              this.readerIndex += readAtMost;
              index += readAtMost;
          }
          return Buffers.wrap(buf);
  
      }
docs: {@inheritDoc}
  
  @throws IOException