### Question:
ByteBufList extends AbstractReferenceCounted { public int getBytes(byte[] dst) { int copied = 0; for (int idx = 0; idx < buffers.size() && copied < dst.length; idx++) { ByteBuf b = buffers.get(idx); int len = Math.min(b.readableBytes(), dst.length - copied); b.getBytes(b.readerIndex(), dst, copied, len); copied += len; } return copied; } private  ByteBufList(Handle<ByteBufList> recyclerHandle); static ByteBufList get(ByteBuf b1, ByteBuf b2); static ByteBufList get(ByteBuf b1); static ByteBufList clone(ByteBufList other); void add(ByteBuf buf); void prepend(ByteBuf buf); int readableBytes(); ByteBuf getBuffer(int index); int size(); int getBytes(byte[] dst); byte[] toArray(); boolean hasArray(); byte[] array(); int arrayOffset(); @VisibleForTesting static ByteBuf coalesce(ByteBufList list); @Override ByteBufList retain(); @Override ReferenceCounted touch(Object hint); static final Encoder ENCODER; static final Encoder ENCODER_WITH_SIZE; }### Answer:
@Test public void testGetBytes() throws Exception { ByteBufList buf = ByteBufList.get(Unpooled.wrappedBuffer("hello".getBytes()), Unpooled.wrappedBuffer("world".getBytes())); assertArrayEquals("helloworld".getBytes(), buf.toArray()); buf.prepend(Unpooled.wrappedBuffer("prefix-".getBytes())); assertArrayEquals("prefix-helloworld".getBytes(), buf.toArray()); byte[] buf100 = new byte[100]; int res = buf.getBytes(buf100); assertEquals("prefix-helloworld".length(), res); byte[] buf4 = new byte[4]; res = buf.getBytes(buf4); assertEquals(4, res); assertEquals("pref", new String(buf4)); }