static public int stringToBytes ( String string , byte [ ] buffer , int index ) { byte [ ] bytes = string . getBytes ( ) ; int length = bytes . length ; System . arraycopy ( bytes , 0 , buffer , index , length ) ; return length ; }
This function converts a string into its corresponding byte format and inserts it into the specified buffer at the specified index .