DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Generate A Table Containing ISO Country Codes Of Every Country And The Name Of The Country In Defined Languages
ISOCountries
public static void main(String[] args) {
String[] codes = java.util.Locale.getISOCountries();
Locale[] displayLocales = new Locale[] { new Locale("fr", "FR"), new Locale("nl", "NL"), new Locale("en", "US") };
for (String isoCode : codes) {
Locale countryLocale = new Locale("", isoCode);
StringBuilder line = new StringBuilder("iso.country." + isoCode.toUpperCase());
for (Locale displayLocale : displayLocales) {
line.append("\t");
line.append(countryLocale.getDisplayCountry(displayLocale));
}
System.out.println(line);
}
}
ISOLanguages
public static void main(String[] args) {
String[] codes = java.util.Locale.getISOLanguages();
Locale[] displayLocales = new Locale[] { new Locale("fr", "FR"), new Locale("nl", "NL"), new Locale("en", "US") };
for (String language : codes) {
Locale locale = new Locale(language);
StringBuilder line = new StringBuilder("iso.language." + language.toUpperCase());
for (Locale displayLocale : displayLocales) {
line.append("\t");
line.append(WordUtils.capitalize(locale.getDisplayLanguage(displayLocale)));
}
System.out.println(line);
}
}





