code: public static String htmlEncode(String s) {
          StringBuilder sb = new StringBuilder();
          char c;
          for (int i = 0; i < s.length(); i++) {
              c = s.charAt(i);
              switch (c) {
              case '<':
                  sb.append("&lt;"); //$NON-NLS-1$
                  break;
              case '>':
                  sb.append("&gt;"); //$NON-NLS-1$
                  break;
              case '&':
                  sb.append("&amp;"); //$NON-NLS-1$
                  break;
              case '\'':
                  //http://www.w3.org/TR/xhtml1
                  // The named character reference &apos; (the apostrophe, U+0027) was introduced in
                  // XML 1.0 but does not appear in HTML. Authors should therefore use &#39; instead
                  // of &apos; to work as expected in HTML 4 user agents.
                  sb.append("&#39;"); //$NON-NLS-1$
                  break;
              case '"':
                  sb.append("&quot;"); //$NON-NLS-1$
                  break;
              default:
                  sb.append(c);
              }
          }
          return sb.toString();
      }
docs: Html-encode the string.
  @param s the string to be encoded
  @return the encoded string