What\'s the most efficient way to put as many bytes as possible from a ByteBuffer bbuf_src
into another ByteBuffer bbuf_dest
(as well as know how m
You get the BufferOverflowException because your bbuf_dest is not big enough.
You will need to use bbuf_dest.remaining() to find out the maximum number of bytes you can transfer from bbuf_src:
int maxTransfer = Math.min(bbuf_dest.remaining(), bbuf_src.remaining());
bbuf_dest.put(bbuf_src.array(), 0, maxTransfer);