Over a million developers have joined DZone.

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);
    }
  }
Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}