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
Post a Comment