package com.able;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class Test {
public static void main(String[] args) {
String str = "able";
String str2;
try {
//将中文转换成百分号编码(URL中需要使用百分号编码)
str2 = URLEncoder.encode(str,"utf-8");
System.out.println(str2);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}