I am of course familiar with the java.net.URLEncoder and java.net.URLDecoder classes. However, I only need HTML-style encoding. (I don’t want ' ' replaced with '+', etc). I am not aware of any JDK built in class that will do just HTML encoding. Is there one? I am aware of other choices (for example, Jakarta Commons Lang ‘StringEscapeUtils’, but I don’t want to add another external dependency to the project where I need this.
I’m hoping that something has been added to a recent JDK (aka 5 or 6) that will do this that I don’t know about. Otherwise I have to roll my own.
Apparently, the answer is, “No.” This was unfortunately a case where I had to do something and couldn’t add a new external dependency for it — in the short term. I agree with everyone that using Commons Lang is the best long-term solution. This is what I will go with once I can add a new library to the project.
It’s a shame that something of such common use is not in the Java API.