Java IO Tutorial - Java Charset.isRegistered()


Charset.isRegistered() has the following syntax.

public final boolean isRegistered()


In the following code shows how to use Charset.isRegistered() method.

import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.Map;
/*from  w ww.ja  v  a 2  s .  c om*/
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);
      if (cs.isRegistered()) {
        System.out.print(" (registered): ");
      } else {
        System.out.print(" (unregistered): ");

The code above generates the following result.