Java Locale getAvailableLocales() Example

Locale class getAvailableLocales() method example. This example shows you how to use getAvailableLocales() method.


Syntax is : public static Locale[] getAvailableLocales()
Methos returns an array of all installed locales. The returned array represents the union of locales supported by the Java runtime environment and by installed LocaleServiceProvider  implementations. It must contain at least a Locale  instance equal to Locale.US.

Here is the code.

/**
 * @(#) GetAvailableLocalesLocale.java
 * A class representing use of method getAvailableLocales() of Locale class
 in java.util Package.
 * @Version  24-May-2008
 @author   Rose India Team
 */
import java.util.*;

class GetAvailableLocalesLocale {
    public static void mainString args[] ){

    /* Create object of Locale class using contructor 
    Locale(String language, String country) */
    Locale[] arr = new Locale[10];
      // getAvailableLocales() method call. This is static method.
        arr = Locale.getAvailableLocales();
        System.out.println("All installed locales are :-\n");
    for(int i=0;i<arr.length;i++ ){
      System.out.println(arr[i]+"............."+arr[i].getDisplayName());
    }
  }
}

Output of the program.
All installed locales are :-

 Installed Locale                         Locale Name
==================            =============
ja_JP.............Japanese (Japan)
es_PE.............Spanish (Peru)
en.............English
ja_JP_JP.............Japanese (Japan,JP)
es_PA.............Spanish (Panama)
sr_BA.............Serbian (Bosnia and Herzegovina)
mk.............Macedonian
es_GT.............Spanish (Guatemala)
ar_AE.............Arabic (United Arab Emirates)
no_NO.............Norwegian (Norway)
sq_AL.............Albanian (Albania)
bg.............Bulgarian

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US