Here you can find the source of encode(String val, String encoding)
public static String encode(String val, String encoding) throws UnsupportedEncodingException
//package com.java2s; /**/*from w w w .j a v a 2 s . c o m*/ * Copyright 2010 ZTEsoft Inc. All Rights Reserved. * * This software is the proprietary information of ZTEsoft Inc. * Use is subject to license terms. * * $Tracker List * * $TaskId: $ $Date: 9:24:36 AM (May 9, 2008) $comments: create * $TaskId: $ $Date: 3:56:36 PM (SEP 13, 2010) $comments: upgrade jvm to jvm1.5 * * */ import java.io.*; public class Main { public static String encode(String val, String encoding) throws UnsupportedEncodingException { if (val == null) { return null; } return new String(val.getBytes(encoding)); } public static String encode(String val, String formEncoding, String toEncoding) throws UnsupportedEncodingException { if (val == null) { return null; } return new String(val.getBytes(formEncoding), toEncoding); } }