print Charsets - Java Internationalization

Java examples for Internationalization:Charset

Description

print Charsets

Demo Code


//package com.java2s;
import java.nio.charset.Charset;
import java.util.Collection;
import java.util.Iterator;

import java.util.Set;
import java.util.SortedMap;

public class Main {
    public static void main(String[] argv) throws Exception {
        printCharsets();//from ww  w.j  a  v  a  2s . c  o m
    }

    public static void printCharsets() {
        SortedMap<String, Charset> charset = Charset.availableCharsets();
        System.out.println("Found " + charset.size() + " charsets");
        Set<String> keys = charset.keySet();
        Collection<Charset> values = charset.values();
        Iterator<Charset> valueI = values.iterator();
        Charset currentValue = null;
        if (valueI.hasNext()) {
            currentValue = valueI.next();
        }
        int i = 0;
        for (String key : keys) {
            System.out.println("Charset " + i + ": " + key + " "
                    + currentValue);
            if (valueI.hasNext()) {
                valueI.next();
            }
            i++;
        }
    }
}

Related Tutorials