MessageFormat
One of the nicest classes in C# is the StringFormatter. I’ve always wanted one in Java. And I just found where they got the idea from. As with the rest of C#: Java. In fact java.text.MessageFormat. D’oh
try {
...
} catch (FileNotFoundException e) {
System.err.println(
MessageFormat.format(
"Could not find file {0} ({1})",
new Object[] {file, e.getMessage()} ) );
}
January 21st, 2003 at 9:39 pm
As much as I do dearly love Java and pretty much despise Microsoft, I have to say that Microsoft beat Sun to the punch on this one.
The real origin of this is the old Microsoft Windows internationalization functions. These date back to at least 1996-7 when I was using them to produce Windows software that ran on both Windows 95 and NT and which could support up to 20 different languages from a single application. The internationalization guys realized that they needed printf but word orders were different for different languages so the simple ordered version of formatting that printf offered was insufficient. Thus code like this was offered even way back then (though it was an OS API call rather than a class that came with C++).