import org.springframework.core.io.ClassPathResource;
ClassPathResource er = new ClassPathResource(".");
String path = er.getFile().getAbsolutePath();
这样就可以得到绝对路径。
ClassPathResource er = new ClassPathResource(".");
String path = er.getFile().getAbsolutePath();
这样就可以得到绝对路径。
本文介绍了一种使用Spring框架中的ClassPathResource类来获取文件绝对路径的方法。通过实例演示了如何加载类路径下的资源并获取其绝对路径。
128

被折叠的 条评论
为什么被折叠?



