Using resource bundles

Resources are simply text files that are accessible to an application. The text files contain information in the format

key=value

and usually are distributed in the path the application classes are located. Class java.util.ResourceBundle makes available the data to an application. Applications read constants or parameters at runtime through methods of class ResourceBundle.

Why using resources?

Using resources has the following advantages

Maintenance: text constants and parameters can be maintained outside the source code. Changing a text constant or parameter does not require code changes. Information is stored in a central place. If a change is necessary, respective part has not to be searched in the whole source code. Constants have to be changed in only one place regardless of whether they are used in multiple places in the source code.

Internationalization : Resources can be replaced in one step without code changes making it easy to switch an application to another language.

Control: Parts of the application can be controlled dynamically through parameters in a resource file rather than having to 'hard wire' them.