public static byte [ ] strToUtf8 ( final String str ) { final ByteBuffer buffer = CHARSET_UTF8 . encode ( str ) ; final byte [ ] bytesArray = new byte [ buffer . remaining ( ) ] ; buffer . get ( bytesArray , 0 , bytesArray . length ) ; return bytesArray ; }
Convert a string into its UTF8 representation .