Displays Charsets and aliases : Charset « I18N « Java






Displays Charsets and aliases

Displays Charsets and aliases
    
// : c12:AvailableCharSets.java
// Displays Charsets and aliases
// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
// www.BruceEckel.com. See copyright notice in CopyRight.txt.

import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.Map;

public class AvailableCharSets {
  public static void main(String[] args) {
    Map charSets = Charset.availableCharsets();
    Iterator it = charSets.keySet().iterator();
    while (it.hasNext()) {
      String csName = (String) it.next();
      System.out.print(csName);
      Iterator aliases = ((Charset) charSets.get(csName)).aliases()
          .iterator();
      if (aliases.hasNext())
        System.out.print(": ");
      while (aliases.hasNext()) {
        System.out.print(aliases.next());
        if (aliases.hasNext())
          System.out.print(", ");
      }
      System.out.println();
    }
  }
} ///:~
           
         
    
    
    
  








Related examples in the same category

1.List the Charset in your system
2.Converting Between Strings (Unicode) and Other Character Set Encodings
3.Charset encoding test
4.encoder and decoder use a supplied ByteBuffer
5.Translate Charset
6.Detect non-ASCII characters in string
7.Encode and DecodeEncode and Decode
8.extends CharsetDecoder to create Base64 Decoder
9.extends Charset to create Hex Charset
10.Get the default charset
11.Charset Toolkit
12.Defines common charsets supported in all Java platforms.
13.How to auto-detect a file's encoding