Java Charset.displayName(Locale locale)

Syntax

Charset.displayName(Locale locale) has the following syntax.

public String displayName(Locale locale)

Example

In the following code shows how to use Charset.displayName(Locale locale) method.


/*  w w  w  . j av  a  2 s.  co  m*/
import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;

public class Main {

  public static void main(String[] args) {
    Map<String, Charset> charsets = Charset.availableCharsets();
    Iterator<Charset> iterator = charsets.values().iterator();
    while (iterator.hasNext()) {
      Charset cs = (Charset) iterator.next();
      System.out.print(cs.displayName(Locale.getDefault()));
    }
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.nio.charset »




Charset
CharsetDecoder
CharsetEncoder
StandardCharsets