Here you can find the source of getEncoder()
public static CharsetEncoder getEncoder()
//package com.java2s; //License from project: Open Source License import java.nio.charset.Charset; import java.nio.charset.CharsetEncoder; public class Main { private static final String ENCODING = "UTF-8"; public static CharsetEncoder getEncoder() { final CharsetEncoder encoder; if (Charset.isSupported(ENCODING)) { // UTF-8 is supported by system encoder = Charset.forName(ENCODING).newEncoder(); } else {//w w w .j a v a 2s . c o m // Use default. encoder = Charset.defaultCharset().newEncoder(); } return encoder; } }