Skip to content

Instantly share code, notes, and snippets.

@bekwam
Last active January 12, 2019 12:53
Show Gist options
  • Save bekwam/18d87c75bea368f954f37774fa3df7de to your computer and use it in GitHub Desktop.
Save bekwam/18d87c75bea368f954f37774fa3df7de to your computer and use it in GitHub Desktop.
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