ResourceBundle : Java Glossary

*0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ (all)

ResourceBundle
A flexible but crude technique for internationalisation. You create multiple classes, one for each locale and the ResourceBundle.getBundle method selects the best fit based on country, language and platform. PropertyResourceBundles get their Strings from a Properties file. A ListResourceBundle is an abstract class. You must extend it with a getContents method that returns an array of of String pairs — the String used in the program and the corresponding String used for that locale. You never actually instantiate a PropertyResourceBundle yourself. getBundle automatically searches for *.properties files.

Note that you give just base name to getBundle. The _cc.properties will automatically be appended. Unlike other resources, the package name is not automatically prepended.

The ResourceBundle properties file must be encoded with ISO-8859-1, not UTF-8. The fancy characters must be encoded with \uxxxx form. You can compose the file in some national encoding then use native2ascii.exe. Unfortunately, the properties file is then no longer readable by humans since all the interesting characters are \uxxxx encoded. Here is what the corresponding *.properties file looks like.

Here is a resource Bundle with

Learning More

Oracle’s Javadoc on ResourceBundle class : available:
Oracle’s Javadoc on PropertyResourceBundle class : available:
Oracle’s Javadoc on ListResourceBundle class : available:
Oracle’s Javadoc on MessageFormat class : available:
Oracle’s Javadoc on Locale class : available:

This page is posted
on the web at:

http://mindprod.com/jgloss/resourcebundle.html

Optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\jgloss\resourcebundle.html
Canadian Mind Products
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

IP:[65.110.21.43]
Your face IP:[54.166.234.171]
You are visitor number