?? e157. converting x-www-form-urlencoded data.txt
字號:
Name/value pairs that are formatted using the x-www-form-urlencoded specification appear as:
name1=value1&name2=value2
where nameN and valueN must be escaped. For example, a+b will appear as a%2Bb when escaped. The URLEncoder and URLDecoder classes are used to escape the names and values.
try {
// Construct a x-www-form-urlencoded string
String line = URLEncoder.encode("name1", "UTF-8") + "=" + URLEncoder.encode("value1", "UTF-8");
line += "&" + URLEncoder.encode("name2", "UTF-8") + "=" + URLEncoder.encode("value2", "UTF-8");
// Parse a x-www-form-urlencoded string
String[] pairs = line.split("\\&");
for (int i=0; i<pairs.length; i++) {
String[] fields = pairs[i].split("=");
String name = URLDecoder.decode(fields[0], "UTF-8");
String value = URLDecoder.decode(fields[1], "UTF-8");
}
} catch (UnsupportedEncodingException e) {
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -