code: public static String encode(String string) {
          int n = string.length();
          char character;
          StringBuffer buffer = new StringBuffer();
          // loop over all the characters of the String.
          for (int i = 0; i < n; i++) {
              character = string.charAt(i);
              // the Htmlcode of these characters are added to a StringBuffer one by one
              if (character < 256) {
                  buffer.append(htmlCode[character]);
              }
              else {
                  // Improvement posted by Joachim Eyrich
                  buffer.append("&#").append((int)character).append(';');
              }
          }
          return buffer.toString();
      }
docs: Converts a <CODE>String</CODE> to the HTML-format of this <CODE>String</CODE>.
  
  @param	string	The <CODE>String</CODE> to convert
  @return	a <CODE>String</CODE>