Before I wander around and throw my own, I was wondering if anyone knew of a way to do the following:
I am currently using MessageFormat to create some lines. Now I have a requirement that some of these lines have a variable number of arguments.
For example (current code):
MessageFormat.format("{0} OR {1}", array[0], array[1]);
Now I need something like:
String s = format(new int[] { 1, 2, 3 });
and
String s = format(new int[] { 1, 2, 3, 4 });
There are several ways that I can think of creating a format string, for example, having 1 string per number of arguments (there are a finite number of them so that it is practical, but it seems bad), or build a string dynamically (there are a lot of them, so it can be slow) .
Any other suggestions?
source
share