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