StringUtil { public static String replace(String pattern, String... tplArgs) { String replaced = pattern; for (int i = 0; i < tplArgs.length; i = i + 2) { replaced = replaced.replace(tplArgs[i], tplArgs[i + 1]); } return replaced; } private  StringUtil(); static String replace(String pattern, String... tplArgs);  }
@Test public void testReplace() { String template = "HelloTPL1WorldTPL2"; template = StringUtil.replace( template, "TPL2", "World", "TPL1", "Hello"); Assert.assertEquals("HelloHelloWorldWorld", template); }