Here you can find the source of encode(String encoding, String string)
public static byte[] encode(String encoding, String string) throws UnsupportedEncodingException
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; public class Main { public static byte[] encode(String encoding, String string) throws UnsupportedEncodingException { if (encoding == null) { return string.getBytes(); } else {//from ww w. ja v a 2 s . c o m return string.getBytes(encoding); } } }