code: public static void enc(char in, StringBuffer out) {
          if (in == '&') {
              out.append("&amp;");
          } else if (in == '<') {
              out.append("&lt;");
          } else if (in == '>') {
              out.append("&gt;");
          } else if (in == '"') {
              out.append("&quot;");
          } else if (in == '\'') {
              out.append("&apos;");
          } else {
              out.append(in);
          }
      }
docs: Appends an XML-appropriate encoding of the given character to the given
  Appendable.
  
  @param in
  The character.
  @param out
  The Appendable to write to. Since we expect only PrintStream,
  PrintWriter, and the String-building classes, we wrap
  the IOException in a RuntimeException