Skip to content

Instantly share code, notes, and snippets.

@thomaslee
Created December 9, 2013 12:20
Show Gist options
  • Save thomaslee/7871444 to your computer and use it in GitHub Desktop.
Save thomaslee/7871444 to your computer and use it in GitHub Desktop.
public final class LittleEndianLengthEncoder extends MessageToByteEncoder<ByteBuf> {
@Override
protected void encode(ChannelHandlerContext channelHandlerContext, ByteBuf in, ByteBuf out) throws Exception {
final ByteOrder order = out.order();
out.order(ByteOrder.LITTLE_ENDIAN)
.writeInt(in.readInt())
.order(order)
.writeBytes(in);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment