代码如下
ClassPathResource resource = new ClassPathResource("/home/tomcat/apache-tomcat-9.0.43/tempPositionStr.properties");
File file = new File(String.valueOf(resource.getFile()));
报错如下:
java.io.FileNotFoundException: class path resource [home/tomcat/apache-tomcat-9.0.43/tempPositionStr.properties] cannot be resolved to URL because it does not exist
从报错的路径来看,home目录前面的斜杠被忽略了?这是为什么?