public static void putString(final ByteBuffer buffer,final String string){
  buffer.putInt(string.length());
  for (int i=0; i < string.length(); i++) {
    buffer.putChar(string.charAt(i));
  }
}

public static void putString ( final ByteBuffer buffer , final String string ) { buffer . putInt ( string . length ( ) ) ; for ( int i = 0 ; i < string . length ( ) ; i ++ ) { buffer . putChar ( string . charAt ( i ) ) ; } }
writes the given string to the bytebuffer . first writes the length of the string as int , then writes the single characters . the bytebuffer ' s position is incremented according to the length of the string .
