File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Abilities of ResourceBundle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Abilities of ResourceBundle" Watch "Abilities of ResourceBundle" New topic
Author

Abilities of ResourceBundle

zaeem masood ashar
Ranch Hand

Joined: Mar 17, 2001
Posts: 54
Hi
Can anyone tell me the how the ResourceBundle of the Java.util package accesses properties from a .properties file?? What exactly happens??
Thanks


SCJP2
rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
check the API at http://java.sun.com/j2se/1.3/docs/api/index.html
Suppose we have a PropertyResourceBundle 'test.properties'. This ResourceBundle contains the keys 'key1' and 'key2'.
try
{
ResourceBundle resb = ResourceBundle.getBundle(test);
String keyValue1 = (String)resb.getObject(this.key1);
String keyValue2 = (String)resb.getObject(this.key2);
}
catch(MissingResourceException e)
{
e.printStackTrace();
}


Cheers,<br />Rani<br />SCJP, SCWCD, SCBCD
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Abilities of ResourceBundle
 
Similar Threads
read a properties file
Resource bundle or Properties
refresh ResourceBundle contents
store config data in xml
PropertyResourceBundle and EL