显示字符集和别名

// : 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();   
    }   
  }   
}

你可能感兴趣的:(java,C++,c,C#)