Isolating Locale-Specific Data with Resource Bundles
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.MissingResourceException;
public class Animals {
public static void main(String [] argv) {
ResourceBundle animalResources;
try {
animalResources = ResourceBundle.getBundle("AnimalResources", Locale.getDefault());
System.out.println(animalResources.getString("Animals"));
} catch (MissingResourceException mre) {
mre.printStackTrace();
}
}
}
//AnimalResources.properties
/*
# Sample properties file with keys whose values span more than one line
#
Animals=Cat, Dog, Giraffe, \
Shark, Dolphin, Bird, \
Bear, Moose
*/
Related examples in the same category