package org.test;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
public class TestEncoding {
/**
* @param args
* @throws UnsupportedEncodingException
*/
public static void main(String[] args) throws UnsupportedEncodingException {
// TODO Auto-generated method stub
//将字符串转换成编码URLEncoder
String message="您上传的文件类型不合法,请重新上传";
System.out.println(URLEncoder.encode(message, "GBK"));
//打印结果 定义为一下变量的值
String encodingResult="%C4%FA%C9%CF%B4%AB%B5%C4%CE%C4%BC%FE%C0%E0%D0%CD%B2%BB%BA%CF%B7%A8%A3%AC%C7%EB%D6%D8%D0%C2%C9%CF%B4%AB";
//将编码转换成字符串URLDecoder
System.out.println(URLDecoder.decode(encodingResult, "GBK"));
}
}