Wednesday, June 19, 2013

ResourceBundle : Loading properties file from JAR

With ResourceBundle you can use properties file which are present in external JAR.
  
getBundle(String baseName,Locale locale)
Where baseName should be the base name of the resource bundle, a fully qualified class name. Which mean it should be fully qualified name of properties excluding .properties extension.

Suppose you have a JAR structure like displayed in following image


(I have renamed the msg.jar to msg.zip just to open it and show the file structure).
Here properties files are in package "com.msg" so baseName should be "com.msg.messages" like
  
getBundle("com.msg.messages", desiredLocale);
For more details : Java Doc Link

No comments:

Post a Comment