dcsimg
How can I specify the key in a property file when accessing its value from ResourceBundle object, if that key contains a whitespace character
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Wednesday, April 11, 2001 10:03 PM

I want to retrieve the value of a key
from the propertie file using ResourceBundle object.

Consider the properties file(say status.properties) as follows...

Java is=Oject Oriented
And is=Platform Independent

These are the two lines in the properties file.

I want to retrievt the first key's value
using resource bundle.
But when using getString(key) method
if that key contains a whitespace character, it is throwing java.util.MissingResourceException.

Pl. give code how to access the value of a key which contains whitespace characters.

Re: How can I specify the key in a property file when accessing its value from ResourceBundle object, if that key contains a whitespace character

Posted By:   Christopher_Schultz  
Posted On:   Monday, May 14, 2001 01:35 PM

Standard operating procedure in these types of properties files is to use a period (.) in between the words of a property's key:



Java.Is=Object Oriented

And.Is=Platform Independent



If you really want to have whitespace in your keys, you should be able to use the backslash () to escape the whitespace character:



Java Is=Object Oriented

And Is=Platform Independent



Then, you can access your values like this:



bundle.getProperty("Java Is");



Good luck,

-chris
About | Sitemap | Contact