/放到main函数中直接执行/
System.out.println(".................URL进行转码.................."); String keyWord = "MLDN 侯上校"; //对内容进行编码 String encod = URLEncoder.encode(keyWord, "UTF-8"); System.out.println("编码后的内容:"+encod); //对内容进行解码 String decod = URLDecoder.decode(encod, "UTF-8"); System.out.println("解码之后的内容:"+decod); System.out.println("..............BASE64进行加密和解密..............."); String str = "MLDN 侯上校"; BASE64Encoder enc = new BASE64Encoder(); BASE64Decoder dec = new BASE64Decoder(); String 加密 = enc.encode(str.getBytes()); System.out.println("加密:"+加密); byte b[] = dec.decodeBuffer(加密); String 解密 = new String(b); System.out.println("解密:"+解密);