private void writeUTFBody(String s) throws IOException {
  int len=s.length();
  for (int off=0; off < len; ) {
    int csize=Math.min(len - off,CHAR_BUF_SIZE);
    s.getChars(off,off + csize,cbuf,0);
    for (int cpos=0; cpos < csize; cpos++) {
      char c=cbuf[cpos];
      if (c <= 0x007F && c != 0)       write(c);
 else       if (c > 0x07FF) {
        write(0xE0 | ((c >> 12) & 0x0F));
        write(0x80 | ((c >> 6) & 0x3F));
        write(0x80 | ((c) & 0x3F));
      }
 else {
        write(0xC0 | ((c >> 6) & 0x1F));
        write(0x80 | ((c) & 0x3F));
      }
    }
    off+=csize;
  }
}

private void writeUTFBody ( String s ) throws IOException { int len = s . length ( ) ; for ( int off = 0 ; off < len ; ) { int csize = Math . min ( len - off , CHAR_BUF_SIZE ) ; s . getChars ( off , off + csize , cbuf , 0 ) ; for ( int cpos = 0 ; cpos < csize ; cpos ++ ) { char c = cbuf [ cpos ] ; if ( c <= 0x007F && c != 0 ) write ( c ) ; else if ( c > 0x07FF ) { write ( 0xE0 | ( ( c > > 12 ) & 0x0F ) ) ; write ( 0x80 | ( ( c > > 6 ) & 0x3F ) ) ; write ( 0x80 | ( ( c ) & 0x3F ) ) ; } else { write ( 0xC0 | ( ( c > > 6 ) & 0x1F ) ) ; write ( 0x80 | ( ( c ) & 0x3F ) ) ; } } off += csize ; } }
writes the " body " ( i . e . , the utf representation minus the 2 - byte or 8 - byte length header ) of the utf encoding for the given string .
