tags:

views:

108

answers:

4

Does anyone know of a Java library that provides support for the ${var} style substitution in text files?

+4  A: 

Velocity ( http://velocity.apache.org ), FreeMarker ( http://freemarker.sourceforge.net/ )

snw
+1  A: 

Don't pass up StringTemplate it is probably the cleanest separation of data and template concerns and is very robust.

fuzzy lollipop
+1  A: 

Java's MessageFormat class allows for semi-advanced text substitution, with localization and formatting support for numbers, dates and time. And for pluralization, you may even use java.text.ChoiceFormat with MessageFormat. It may be enough for all your text-substitution needs.

If not, you can take a look at Apache Velocity (http://velocity.apache.org/) or Freemarker(http://freemarker.sourceforge.net/)

Olivier Croisier
Good to know that Sun has their own built-in tool for this. It works well if you don't want to include any other libraries. It is also available in Java 1.4 and 5.
Alex Beardsley