Liny_@NotePad

沉迷ACG中

相对ClassPath getResource目录名带中文或空格问题解决

YOYO posted @ 2009年11月23日 07:06 in 【Java SE】 , 3879 阅读

原来是

getClass().getClassLoader().getResource(".").getPath()

在遇到中文或空格时会转成utf-8格式显示(如空格显示%20),此时用java.net.URLDecorder来转码即可。

URLDecoder.decode(getClass().getClassLoader().getResource(".").getPath(), "utf-8")
  • 无匹配

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter