如何解决路径中的非法字符异常? [英] How to solve the exception Illegal character in path?

查看:163
本文介绍了如何解决路径中的非法字符异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用XML解析显示来自URL的图像,并且某些图像显示得很好,但有时会出现类似

I am displaying images from an URL using XML parsing and some images are displaying very well, but sometimes I get exception like

索引113路径中的非法字符: http://www.theblacksheeponline.com/party_img/thumbspps/12390867930_15951_186997180114_709920114_4296270_6115611_n[1].jpg

如何解决此问题,请提供一些示例代码...

How to solve this problem, please provide some sample code...

推荐答案

特殊字符需要转义,例如[code]为%5B ,]为

Special characters need escaping such as %5B for [ and %5D for ]

您可以像

java.net.URLEncoder

URLEncoder.encode(myurltoencode,"UTF-8");

URLEncoder.encode(myurltoencode,"UTF-8");

这不仅可以解决[或],还可以解决其他编码问题

This will not just fix the [ or ] but also other encoding issues

这篇关于如何解决路径中的非法字符异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆