Java Cookbook
How to get an array of available lLocales
Problem:
You want to list all locales your system supports.
Solution:
To get an array of all installed locales you can use the static getAvailableLocales method. This retrieves the full locales, and not only their ids.
To loop through available locales and output their ids:
Locale[] locales = Locale.getAvailableLocales();
for(int x = 0; x < locales.length; x++){
System.out.println(locales[x].toString());
}
If you are testing any of these recipes in Eclipse and the characters are not displaying correctly in your console visit http://i18ncookbook.com/eclipse_settings.
This site is ad supported. I hope you find something among our sponsors worth clicking. ;)
i18n search
Custom Search