1. 程式人生 > >URLEncoder編碼及URLDecoder解碼使用方法

URLEncoder編碼及URLDecoder解碼使用方法

package com.hyn;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

public class DemoUrlEncode {

	public static void main(String[] args) throws UnsupportedEncodingException {
		String strUrlEn = URLEncoder.encode("http://www.baidu.com", "utf-8");
		System.out.println(strUrlEn);
		String strUrlDe = URLDecoder.decode(strUrlEn, "utf-8");
		System.out.println(strUrlDe);
	}
}

ng strUrlDe = URLDecoder.decode(strUrlEn, "utf-8");System.out.println(strUrlDe);}}