Here you can find the source of encode(String src, String charset)
public static byte[] encode(String src, String charset)
//package com.java2s; import java.io.UnsupportedEncodingException; public class Main { public static byte[] encode(String src, String charset) { if (src == null) { return null; }//from ww w . j a v a2 s. c o m try { return src.getBytes(charset); } catch (UnsupportedEncodingException e) { return src.getBytes(); } } }