java.util.MessageFormat.
Alternatively, and in a much more powerful way, save your template as XML with tags for the parameters you want to replace; use XSLT for substitution and XPath for extracting only text from an XML document after processing.
source
share