public static byte [ ] getBytes ( String string ) { byte [ ] result = new byte [ utf8Length ( string ) ] ; try { // avoid sync'd allocations writeChars ( result , string , 0 , string . length ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } return result ; }
Convert a string to a UTF - 8 encoded byte array .