Skip to content

Instantly share code, notes, and snippets.

@bigdragon1977
Created November 13, 2014 09:03
Show Gist options
  • Select an option

  • Save bigdragon1977/6f9909f5bbada7b79573 to your computer and use it in GitHub Desktop.

Select an option

Save bigdragon1977/6f9909f5bbada7b79573 to your computer and use it in GitHub Desktop.
Netty java getting data from ByteBuf
ByteBuf buf = ...
byte[] bytes = new byte[buf.readableBytes()];
buf.readBytes(bytes);
//If you don't want the readerIndex to change:
ByteBuf buf = ...
byte[] bytes = new byte[buf.readableBytes()];
int readerIndex = buf.readerIndex();
buf.getBytes(readerIndex, bytes);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment