I'm not sure why the following example gives buffer overflow exception. Hope someone can explain why, and how i can do it correctly.
It's as simple as this:
ByteBuffer bf = ByteBuffer.allocate(4);
bf.order(ByteOrder.BIG_ENDIAN);
bf.putInt(8);
bf.putInt(7); // Throws exception
The goal: [0,0,8,7]
Thanks in advance!