Resource bundle instances created by the getBundle factory methods are cached by default, and the factory methods return the same resource bundle instance multiple times if it has been cached. getBundle clients may clear the cache, manage the lifetime of cached resource bundle instances using time-to-live values, or specify not to cache resource bundle instances. Refer to the descriptions of the getBundle factory method, clearCache, ResourceBundle.Control.getTimeToLive, and ResourceBundle.Control.needsReload for details.
Censorship is the younger of two shameful sisters, the older one bears the name inquisition. -- Johann Nepomuk Nestroy
Joined: Jan 15, 2010
now, if i use bundle to get a properties file. how can i make the bundle reload when the properties file changes? or reload every defined time?
clearCache() doesnt do the job..
Joined: Nov 18, 2006
I tried to do something similar a few years ago and never got it running. Afaik a resource bundle cannot be easily updated / reread. And you cannot simply extend ResourceBundle and provide your own implementation because most of it's members are private (you'd have to implement it from scratch).
To refresh the contents of a bundle you have to clear the cache (even that wasn't possible before Java 6!) and reread the bundle:
Of course, for the example to work you have to add '.' (executing directory) to your classpath ; - )