import java.net.URLDecoder; import java.net.URLEncoder; //================================================= // File Name : URL_demo //------------------------------------------------------------------------------ // Author : Common //主类 //Function : URL_demo public class URL_demo { public static void main(String[] args) throws Exception { // TODO 自动生成的方法存根 String keyWord = "张三"; String encod = URLEncoder.encode(keyWord,"UTF-8"); //对内容进行编码 System.out.println("编码之后的内容:"+encod); String decod = URLDecoder.decode(keyWord,"UTF-8"); //对内容进行编码 System.out.println("解码之后的内容:"+decod); } }