question: public static String toString ( ByteBuffer bb ) { byte [ ] bytes = new byte [ bb . getInt ( ) ] ; String s = "" ; try { if ( ArrayUtils . isNotEmpty ( bytes ) ) { bb . get ( bytes ) ; s = new String ( bytes , UTF8 ) ; } } catch ( Exception e ) { throw new RuntimeException ( "ByteBuffer not in expected format," + " failed to parse string bytes" , e ) ; } return s ; }
target:  This assumes the next position is the size as an int, and the following is a string if the size is not zero.