static public byte [ ] extract ( ByteBuffer buf ) { int len = buf . limit ( ) ; byte [ ] bytes = new byte [ len ] ; buf . rewind ( ) ; buf . get ( bytes ) ; return bytes ; }
Properly extract the byte contents of a ByteBuffer