static void writeUTF(OutputStream out,String str) throws IOException {
  for (int i=0, len=str.length(); i < len; i++) {
    int c=str.charAt(i);
    if ((c >= 0x0001) && (c <= 0x007F)) {
      out.write(c);
    }
 else {
      if (c > 0x07FF) {
        out.write(0xE0 | ((c >> 12) & 0x0F));
        out.write(0x80 | ((c >> 6) & 0x3F));
        out.write(0x80 | ((c >> 0) & 0x3F));
      }
 else {
        out.write(0xC0 | ((c >> 6) & 0x1F));
        out.write(0x80 | ((c >> 0) & 0x3F));
      }
    }
  }
}

static void writeUTF ( OutputStream out , String str ) throws IOException { for ( int i = 0 , len = str . length ( ) ; i < len ; i ++ ) { int c = str . charAt ( i ) ; if ( ( c >= 0x0001 ) && ( c <= 0x007F ) ) { out . write ( c ) ; } else { if ( c > 0x07FF ) { out . write ( 0xE0 | ( ( c > > 12 ) & 0x0F ) ) ; out . write ( 0x80 | ( ( c > > 6 ) & 0x3F ) ) ; out . write ( 0x80 | ( ( c > > 0 ) & 0x3F ) ) ; } else { out . write ( 0xC0 | ( ( c > > 6 ) & 0x1F ) ) ; out . write ( 0x80 | ( ( c > > 0 ) & 0x3F ) ) ; } } } }
write a utf string with a length to a stream .
