Are there constants for language code in Java or Java libraries?

Do language codes in Java or Java libraries (such as "en" or "de") have constants? (or use string OK?)

I know such things

Locale.COUNTRY-NAME.getLanguage()

I can work, but I'm looking for something smoother

Locale.LANGUAGE-NAME

Solution

I'm afraid I don't have constants for all languages

To get all the language code supported by the underlying JVM, use getisolanguages()

for(String lang : Locale.getISOLanguages()) {
  System.out.println(lang);
}

More details: http://download.oracle.com/javase/1.4.2/docs/api/java/util/Locale.html

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>