Java tutorial
//package com.java2s; import java.io.UnsupportedEncodingException; public class Main { /** * Convert %XX * * @param value * @return */ public static String formParamDecode(String value) { int nCount = 0; for (int i = 0; i < value.length(); i++) { if (value.charAt(i) == '%') { i += 2; } nCount++; } byte[] sb = new byte[nCount]; for (int i = 0, index = 0; i < value.length(); i++) { if (value.charAt(i) != '%') { sb[index++] = (byte) value.charAt(i); } else { StringBuilder sChar = new StringBuilder(); sChar.append(value.charAt(i + 1)); sChar.append(value.charAt(i + 2)); sb[index++] = Integer.valueOf(sChar.toString(), 16).byteValue(); i += 2; } } String decode = ""; try { decode = new String(sb, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return decode; } }