From the course: Java SE 17 Developer (1Z0-829) Cert Prep

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

ResourceBundle and data lookup

ResourceBundle and data lookup - Java Tutorial

From the course: Java SE 17 Developer (1Z0-829) Cert Prep

ResourceBundle and data lookup

- Now let's investigate ResourceBundles and looking up data in them. Java provides a mechanism for loading resources that are specific to a locale. The simplest form uses properties files. These contain textual key-values pairs. The file names of the property files include locale descriptions. And the system loads properties from the best matching file that it can find that actually contains the property being asked for. Language will be the most important piece of the file name, and geographic region is next. Additional elements might be considered if they're in use. So property files are named in this pattern, something like Resources.properties. The properties extension indicates that we have key-value pairs, and then Resources is the name you get to choose. If you have an English-specific version, you might have Resources_en.properties. If you have an American English version of this, that could be represented as Resources_en_US.properties. If there is a British English version…

Contents