Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

MessageFormat not picking up placeholders?  RSS feed

 
dave taubler
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have what I thought would be a simple use case for a MessageFormat to do String replacement. I have a String (template) that looks similar to the one below:


I then create a String array (replacers) consisting of two Strings. Then, I pass those two arguments to a method like the one below:

It always throws an IllegalArgumentException, because for some reason the MessageFormat only thinks there is one replacement to be made. If I comment out the chunk that throws that Exception, and it is able to print the logging message, it will print:


There's gotta be something simple that I am missing here, as to why MessageFormat would overlook a substitution like that. Can anyone think of anything?

[ October 07, 2004: Message edited by: dave taubler ]
[ October 07, 2004: Message edited by: dave taubler ]
 
dave taubler
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind... in my original template String, I had an apostrophe, which I guess the MessageFormat took as a single-quote. Single-quotes need to be escaped with another single-quote (e.g. '').
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!