Created
July 3, 2012 05:51
-
-
Save trustin/3037950 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.netty.buffer.ByteBuf; | |
import io.netty.buffer.Unpooled; | |
import java.nio.ByteOrder; | |
ByteBuf buf = Unpooled.buffer(4); | |
buf.setInt(0, 1); | |
// Prints '00000001' | |
System.out.format("%08x%n", buf.getInt(0)); | |
ByteBuf leBuf = buf.order(ByteOrder.LITTLE_ENDIAN); | |
// Prints '01000000' | |
System.out.format("%08x%n", leBuf.getInt(0)); | |
assert buf != leBuf; | |
assert buf == buf.order(ByteOrder.BIG_ENDIAN); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment