在java中获取文件路径的时候,有时候会获取到空格,但是在中文编码环境下,空格会变成“%20”从而使得路径错误,解决办法如下: String path=Parameter.class.getResource("").getPath();//得到路径 path=URLDecoder.decode(path,"utf-8");//关键 !