this.getClass().getResource("").getPath() 获取文件路径时,若包含空格,url中则会出现'%20', 导致出现找不到路径的错误 解决方案: 可以把路径中包含中文问题一并处理掉 String configPath = java.net.URLDecoder.decode(this.getClass().getResource("").getPath(),"utf-8"); Document document = reader.read(new File(configPath+"\\channel.xml"));