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