Java Charset.toString()

Syntax

Charset.toString() has the following syntax.

public final String toString()

Example

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


//from   w  w w.  java2s .c o m
import java.nio.charset.Charset;
import java.util.Iterator;
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.println(cs.displayName());
      System.out.println(cs.toString());
    }
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.nio.charset »




Charset
CharsetDecoder
CharsetEncoder
StandardCharsets