Here you can find the source of getCharset(String encoding)
static final Charset getCharset(String encoding)
//package com.java2s; // Apache License import java.nio.charset.Charset; import java.util.HashMap; public class Main { private static final HashMap charsets = new HashMap(); static final Charset getCharset(String encoding) { Charset charset = (Charset) charsets.get(encoding); if (charset == null) { charset = Charset.forName(encoding); charsets.put(encoding, charset); }//from w w w . j a v a 2 s.c o m return charset; } }