tags:

views:

150

answers:

2

I used following code, but it displays only 2 digit of ISO country name. For example, for "INDIA", it only display "IN". Can I show full name as "INDIA" ?

String[] loc= Locale.getISOCountries();
for(int a=0;a<loc.length;a++)
{
    System.out.println("ISO Contry "+a+":"+loc[a]);
}

I want full name of ISO country. Is it possible to get using this method?

+2  A: 

Try using getDisplayCountry() method.

Example:

import java.util.Locale;

public class Main {

  public static void main(String [] argv) {

    Locale defaultLocale = Locale.getDefault();
    System.out.println(defaultLocale.getDisplayCountry()); // displays United States
  }
}

EDIT: To get the complete list of full country names, I'm not aware of any methods. Instead what you can do is, download this ISO 3166 Codes which contains the mapping of full country name to 2-letter to two letter ISO 3166 name, use your earlier getISOCountries method to get the 2 letter name and use the mapping.

codaddict
Yes, thanks for answer. I tried and getDisplaycountry() method works nincely. But i can get only single Country in ISO countries which is already available in those countries. How to get all countries name?
Venkats
Venkats: I've updated my answer.
codaddict
A: 

import java.util.*;

public class Locales { public static void main(String[] args) { Locale[] locales = Locale.getAvailableLocales(); for(int i = 0; i < locales.length; i++) { String locale_name = locales[i].getDisplayName(); System.out.println((i+1)+":"+locale_name); } } }

Here we can get onlyfull name of Locale which are available in getAvailableLocale() method.

Venkats