Wednesday, February 12, 2014

Get list of all country with iso3 and code from locale using java


package pritom;

import java.util.Locale;

/**
 * Created by pritom on 12/02/14.
 */
public class CheckCountry {
    public static void main(String[] args) {
        String[] isoCountries = Locale.getISOCountries();
        for (String country : isoCountries) {
            Locale locale = new Locale("en", country);
            String code = locale.getISO3Country();
            String name = locale.getCountry();
            String displayName = locale.getDisplayCountry();
            System.out.println("ISO3 Code: " + code + " , Name: " + name + " , Display: " + displayName);
        }
    }
}

Some example output of this code:


.
.
.
ISO3 Code: AUT , Name: AT , Display: Austria
ISO3 Code: AUS , Name: AU , Display: Australia
ISO3 Code: ABW , Name: AW , Display: Aruba
ISO3 Code: ALA , Name: AX , Display: Ă…land Islands
ISO3 Code: AZE , Name: AZ , Display: Azerbaijan
ISO3 Code: BIH , Name: BA , Display: Bosnia and Herzegovina
ISO3 Code: BRB , Name: BB , Display: Barbados
ISO3 Code: BGD , Name: BD , Display: Bangladesh
.
.
.

No comments:

Post a Comment