I\'m sure I\'ve seen String.format
used like this before:
String.format(\"Some {1}, {2}, {3}\", var1, var2, var3);
Does this ring
If you want to use empty placeholders (without positions), you could write a small utility around Message.format()
, like this
String format(String s, Object... var2) {
int i = 0;
while(s.contains("{}")) {
s = s.replaceFirst(Pattern.quote("{}"), "{"+ i++ +"}");
}
return MessageFormat.format(s, var2);
}
And then, can use it like,
format("Some {} {} {}", var1, var2, var3);