Charset.availableCharsets() has the following syntax.
public static SortedMap<String, Charset> availableCharsets()
In the following code shows how to use Charset.availableCharsets() method.
//from w ww . ja va 2 s .c om 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.