Wednesday, 15 April 2015

buffer - Java Bytebuffer overwrite bytes -



buffer - Java Bytebuffer overwrite bytes -

i've got bytebuffer contains 1024 bytes.

i need overwrite short within buffer @ offset @ key times.

i know bytebuffer class has putshort(), doesn't overwrite data, adds in, causing buffer overflows.

i'm guessing there isn't direct way of doing using bytebuffer, can perchance suggest way this?

thanks

thanks replied, seemed done using wrong version of putshort(). guess that's happens when stare @ same piece of code 6 hours.

thanks again

cannot reproduce problem, seems ok

bytebuffer bb = bytebuffer.allocate(20); bb.putshort(10, (short)0xffff); system.out.println(arrays.tostring(bb.array()));

prints

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0]

java buffer byte

No comments:

Post a Comment