Suppose that I have 2 ByteBuffer containing some bytes in it... How would be the best way to append all the content of one ByteBuffer with other? I'm doing this but it throws a BufferUnderFlowException:
ByteBuffer allData = ByteBuffer.allocate(999999);
ByteBuffer buff = null;
for (int i = 0; i < n; i++) {
buff = aMethodThatReturnsAFilledByteBuffer();
allData.put(buff);
}
What I'm doing wrong? Thanks in advance.