Skip to content

Instantly share code, notes, and snippets.

@bekwam
Last active January 12, 2019 12:53
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
public class ByteBufferTest {
public static void main(String[] args) {
byte[] a = new byte[2];
a[0] = (byte)0xff;
a[1] = (byte)0xcc;
ByteBuffer byteBuffer = ByteBuffer.allocate(2);
byteBuffer.put( a );
byteBuffer.flip();
byte[] b = new byte[2];
byteBuffer.get(b, 0, 2);
System.out.println( String.format("%x %x", b[0], b[1]) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment