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?
What about trying the following:
Personally this I think it's even more clear and you can use the full 32 bits.
I'm disregarding the flags here, you could pass those separately. I've changed the answer in such a way that the position of the buffer is placed at the end of the size.