How to use resourcebundle to avoid hard coding configuration paths in Java applications?
I want to eliminate the dependency of hard coded path of configuration data in my java application. I know that using resourcebundle will help me find resources using classloader
Can someone tell me how to replace the hard coded path of resources (such as the. Properties configuration data file required by a class) by using resourcebundle appropriately? If possible, simple and clear examples, thank you
Solution
Prior to Java 6, resourcebundles typically allowed:
>Add strings from a set of localized property files using propertyresourcebundle > objects from a set of localized classes using listresourcebundle
Java 6 comes with resourcebundle Control class, which opens the door to other resourcebundles sources, such as:
>XML file (see example 2 in Javadoc) > database line
I hope this will help