Android开发:URLDecoder: Illegal hex characters in escape (%) pattern : %编码问题

一、问题如下

  1、问题异常:在用Java调用 URLDecoder.decode(result, "UTF-8");时 抛出以下的异常:

  W/System.err: java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern : %

  

 二、问题解决

  1、问题分析:导致上述异常的主要原因是% 在URL中是特殊字符,需要特殊转义一下。

  2、问题解决:使用%25替换字符串中的%号:

result=result.replaceAll("%(?![0-9a-fA-F]{2})","%25");
原文地址:https://www.cnblogs.com/guobin-/p/12570278.html