public static void writeStringData(ByteBuffer buff,String s,int len){
  for (int i=0; i < len; i++) {
    int c=s.charAt(i);
    if (c < 0x80) {
      buff.put((byte)c);
    }
 else     if (c >= 0x800) {
      buff.put((byte)(0xe0 | (c >> 12)));
      buff.put((byte)(((c >> 6) & 0x3f)));
      buff.put((byte)(c & 0x3f));
    }
 else {
      buff.put((byte)(0xc0 | (c >> 6)));
      buff.put((byte)(c & 0x3f));
    }
  }
}

public static void writeStringData ( ByteBuffer buff , String s , int len ) { for ( int i = 0 ; i < len ; i ++ ) { int c = s . charAt ( i ) ; if ( c < 0x80 ) { buff . put ( ( byte ) c ) ; } else if ( c >= 0x800 ) { buff . put ( ( byte ) ( 0xe0 | ( c > > 12 ) ) ) ; buff . put ( ( byte ) ( ( ( c > > 6 ) & 0x3f ) ) ) ; buff . put ( ( byte ) ( c & 0x3f ) ) ; } else { buff . put ( ( byte ) ( 0xc0 | ( c > > 6 ) ) ) ; buff . put ( ( byte ) ( c & 0x3f ) ) ; } } }
write characters from a string ( without the length ) .
