static public void writeText(Writer out,char[] buff,String text) throws IOException {
  int buffLength=buff.length;
  int buffIndex=0;
  int length=text.length();
  for (int i=0; i < length; i++) {
    char ch=text.charAt(i);
    if (ch < 0xA0) {
      if (ch >= 0x3f) {
        buffIndex=addToBuffer(out,buff,buffIndex,buffLength,ch);
      }
 else       if (ch >= 0x27) {
        if (ch < 0x3c) {
          buffIndex=addToBuffer(out,buff,buffIndex,buffLength,ch);
        }
 else         if (ch == '<') {
          buffIndex=flushBuffer(out,buff,buffIndex);
          out.write("&lt;");
        }
 else         if (ch == '>') {
          buffIndex=flushBuffer(out,buff,buffIndex);
          out.write("&gt;");
        }
 else {
          buffIndex=addToBuffer(out,buff,buffIndex,buffLength,ch);
        }
      }
 else {
        if (ch == '&') {
          buffIndex=flushBuffer(out,buff,buffIndex);
          out.write("&amp;");
        }
 else {
          buffIndex=addToBuffer(out,buff,buffIndex,buffLength,ch);
        }
      }
    }
 else {
      buffIndex=flushBuffer(out,buff,buffIndex);
      _writeDecRef(out,ch);
    }
  }
  flushBuffer(out,buff,buffIndex);
}

static public void writeText ( Writer out , char [ ] buff , String text ) throws IOException { int buffLength = buff . length ; int buffIndex = 0 ; int length = text . length ( ) ; for ( int i = 0 ; i < length ; i ++ ) { char ch = text . charAt ( i ) ; if ( ch < 0xA0 ) { if ( ch >= 0x3f ) { buffIndex = addToBuffer ( out , buff , buffIndex , buffLength , ch ) ; } else if ( ch >= 0x27 ) { if ( ch < 0x3c ) { buffIndex = addToBuffer ( out , buff , buffIndex , buffLength , ch ) ; } else if ( ch == '<' ) { buffIndex = flushBuffer ( out , buff , buffIndex ) ; out . write ( "&lt;" ) ; } else if ( ch == '>' ) { buffIndex = flushBuffer ( out , buff , buffIndex ) ; out . write ( "&gt;" ) ; } else { buffIndex = addToBuffer ( out , buff , buffIndex , buffLength , ch ) ; } } else { if ( ch == '&' ) { buffIndex = flushBuffer ( out , buff , buffIndex ) ; out . write ( "&amp;" ) ; } else { buffIndex = addToBuffer ( out , buff , buffIndex , buffLength , ch ) ; } } } else { buffIndex = flushBuffer ( out , buff , buffIndex ) ; _writeDecRef ( out , ch ) ; } } flushBuffer ( out , buff , buffIndex ) ; }
write string text . note that this code is duplicated above for character arrays - change both places if you make any changes ! ! !
