I need to get 64-bit little-endian integer as byte-array with upper 32 bits zeroed and lower 32 bits containing some integer number, let say it's 51.
Now I was doing it in this way:
byte[] header = ByteBuffer
.allocate(8)
.order(ByteOrder.LITTLE_ENDIAN)
.putInt(51)
.array();
But I'm not sure is it the right way. Am I doing it right?
intis 32 bits. Moreover,ByteBuffer.allocatetakes a number of bytes, not a number of bits, so yourByteBufferhas sixty zero bytes at the end.