java - Why do bytebuffer give buffer overflow exception when buffer is not full -


i'm not sure why following example gives buffer overflow exception. hope can explain why, , how can correctly.

it's simple 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!

an int 4 bytes long should multiply 4 number of int need store in bytebuffer.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -