To replace placeholders with exact ones, as you use in the example, you can use StrinUtils.replaceEach
org.apache.commons.lang.StringUtils.replaceEach( "http://server/{x}/{y}/{z}/{t}/{a}.json", new String[]{"{x}","{y}","{z}","{t}","{a}"}, new String[]{"1","2","3","4","5"});
However, MessageFormat will be more efficient, but requires replacing x with 0, y with 1, etc.
If you change your format to
"http://server/${x}/${y}/${z}/${t}/${a}.json",
you can use Velocity , which has a parser specializing in searching for events $ {and}.
The most efficient way would be to write your own parser that will look for the next {{{{{{{{{{{{{{{{}}}} than} than replace the placeholder.
source share