• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MessageFormat not picking up placeholders?

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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. '').
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic