Geos, I would recommend using the Apache Velocity library http://velocity.apache.org/ . This is a template for strings. You, for example, will look like
this is a good example with 234 songs this is $type example with $number songs
The code for this will look like
final Map<String,Object> data = new HashMap<String,Object>(); data.put("type","a good"); data.put("number",234); final VelocityContext ctx = new VelocityContext(data); final StringWriter writer = new StringWriter(); engine.evaluate(ctx, writer, "Example templating", "this is $type example with $number songs"); writer.toString();
source share