Here you can find the source of getCharset(String enc)
public static Charset getCharset(String enc)
//package com.java2s; import java.nio.charset.Charset; import java.util.concurrent.ConcurrentHashMap; public class Main { private static final ConcurrentHashMap<String, Charset> encodingToCharsetCache = new ConcurrentHashMap<String, Charset>(); /**/*from w w w . ja va 2 s .co m*/ * Returns the Java Charset that should be used for the provided encoding */ public static Charset getCharset(String enc) { Charset charset = encodingToCharsetCache.get(enc); if (charset == null) { charset = Charset.forName(enc); encodingToCharsetCache.put(enc, charset); } return charset; } }