private byte[] getBufferBytes() {
byte[] bs = new byte[buffer.getLast().getTotalSize()];
int pos = 0;
ByteBuffer currentBuffer = buffer;
while (currentBuffer != null) {
System.arraycopy(currentBuffer.getBytes(), 0, bs, pos, currentBuffer.getUsedSize());
pos += currentBuffer.getUsedSize();
currentBuffer = currentBuffer.getNext();
}
return bs;
}