获得资源文件地址

sysPath = this.getClass().getResource("").toURI().getPath().replaceAll("tools", "resources") + getFileName();

 

tools,resources是测试用的文件夹名称,getFileName()是具体资源文件名称。通过this.getClass().getResource("").toURI().getPath()来获得资源文件所在目录地址,此地址名称中可包括空格等信息。

你可能感兴趣的:(获得资源文件地址)