Go to
http://www.mousetech.com/EJBWizard.html and download a copy of the source code. In file XMLWriter.java you'll see an example where outgoing data is converted to do escapes on the 5 magic HTML characters (& <, &rt; " and &apos
. It's pretty simple code with no dependencies on the rest of the system.
I don't remember if it uses StringBuffers or not. It's not used heavily enough to make a difference. The MacroParser module DOES use StringBuffer, but it's a lot harder to pick apart, since its a complex component of a larger and even more complex system.
Of course, if the substitution in question was for the purposes of escaping XML or HTML, you can use XMLWriter "as is".
BTW, this really wasn't the proper place to ask a general
Java question, since it has nothing to do with JSP's.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.