• Post Reply Bookmark Topic Watch Topic
  • New Topic

ResourceBundle question - why .properties extension  RSS feed

 
Varun Chopra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
statement

works when filename has .properties extension, otherwise not. How can I use a different extension?
[ October 15, 2008: Message edited by: Varun Chopra ]
 
Thomas Thevis
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Sun's javdocs for java.util.ResourceBundle#getBundle(String baseName, Locale locale, ClassLoader loader):
...Otherwise, getBundle attempts to locate a property resource file. It generates a path name from the candidate bundle name by replacing all "." characters with "/" and appending the string ".properties". It attempts to find a "resource" with this name using ClassLoader.getResource. (Note that a "resource" in the sense of getResource has nothing to do with the contents of a resource bundle, it is just a container of data, such as a file.) If it finds a "resource", it attempts to create a new PropertyResourceBundle instance from its contents. If successful, this instance becomes the result resource bundle....

Maybe you can provide another ClassLoader if you really need to used other file extesions.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think using ResourceBundle.Control would be better. You would definitely need to override newBundle since it explicitly checks for .class or .properties as extensions.
 
Varun Chopra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Thomas and Rob.
 
Ove Lindström
Ranch Hand
Posts: 326
Android Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I use a different extension?



May I ask why you want/need to use another extension??
 
Varun Chopra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't need it, but .properties sound too long to me, also sometime I may like .conf extension based on purpose of file. A matter of feeling, not a real requirement.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!