I have a Java application that makes heavy use of a large file, to read, process and give through to SolrEmbeddedServer (http://lucene.apache.org/solr/).
One of the func
Apache Commons Lang has a very efficient escapeHtml method in its StringEscapeUtils class.
It's fairly smart about it, and doesn't use string replacement in the way you describe, but instead iterates through the characters, replacing characters with appropriate entities as it finds them.
I don't have any benchmarks handy, but if this stuff is on the critical path of your code, you would be wiese to use this off-the-shelf, faster solution.