Byte buffer alternative

1.3k views Asked by At

I am trying find an alternative for a byteBuffer.putShort method. I want same functionality of putshort. So we have any? My jdk (1.4.2) does not support Byte buffer.

Regards Sailaja

1

There are 1 answers

0
Terje On

putShort() does nothing special. The ByteBuffer has information on whether its BigEndian or LittleEndian, - unsure whether your problem needs to consider this. If you do, you need to flip the bytes. Otherwise, it just stores to a backing byte array, and splits the short value into bytes like: byte1 = (byte)(myShort >> 8); byte2 = (byte)(myShort >> 0);