Rhed
Rhed

Reputation: 47

netty 4.1 ByteBuf endian accessing bytes

Hi we have been using netty 4.0 for a while and are moving over to 4.1. For legacy reasons we are receiving messages in little endianness and cant, in the foreseeable future, move over to big endianness.

What we used to do is use the use the "ByteBuf.order(ByteOrder endianness)" method to ensure we access the bytes in little endian. Now that method has become deprecated and the javadoc suggests to use the appropriate little endian version of the given methods; Like getIntLe instead of getInt.

This is all fine and dandy for those methods with a provided alternative. But I also need to access the raw bytes through the getBytes(...) method.

I have little experience with endianness but from what i have read if i access the bytes as is they would be in the reverse order.

My question hence does netty 4.1 provide a different way to access the bytes in a ByteBuf for little endians or to reorder the content?

Thanks in advance

Upvotes: 0

Views: 675

Answers (1)

Norman Maurer
Norman Maurer

Reputation: 23567

There is no different when accessing the bytes directly even when using ByteBuffer.order(...). So just use the getBytes(...).

Upvotes: 2

Related Questions