JAVA网络编程URL编解码

import java.net.URLDecoder;
import java.net.URLEncoder;

public class CodeDemo {
    public static void main(String[] args) throws Exception {
        String keyWord = "哇哈哈";
        String encode = URLEncoder.encode(keyWord, "UTF-8");
        System.out.println("编码之后的内容:"+encode);
        String decode = URLDecoder.decode(encode, "UTF-8");
        System.out.println("解码之后的内容:"+decode);
    }
}
posted @ 2020-12-11 21:14  xl4ng  阅读(121)  评论(0编辑  收藏  举报