in java my file paths with included spaces show up as %20 and i'm not sure why

ⅰ亾dé卋堺 提交于 2019-12-13 07:54:10

问题


I have a photo selection model, but for some reason whenever I call the path of the images, the space in the path is converted to it's HTML code and I'm not sure why. Do any of you have any ideas? Thanks for any help you can spare.


回答1:


It's url encoded. I dont know the java library to un-encode but I'm sure it's out there and fairly easy to use.

edit - http://download.oracle.com/javase/1.4.2/docs/api/java/net/URLDecoder.html

this maybe?




回答2:


The specification for URLs (RFC 1738, Dec. '94) says:

Thus, only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters used for their reserved purposes may be used unencoded within a URL.

And we have:

  1. Space = decimal code point 32 in the ISO-Latin set.
  2. 32 decimal = 20 in hexadecimal
  3. The URL encoded representation will be "%20"


来源:https://stackoverflow.com/questions/5474345/in-java-my-file-paths-with-included-spaces-show-up-as-20-and-im-not-sure-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!