String filePath="test.txt"
org.springframework.core.io.Resource resource = new ClassPathResource(
filePath);
File file=resource.getFile();
filePath放在类路径下。也就是工程的src文件夹下面。编译后会到WEB-INF下面的classes文件夹下面。
本文详细介绍了如何使用Spring框架获取位于类路径下的资源文件,并解析了文件路径的使用场景,包括编译后文件的位置变化。
String filePath="test.txt"
org.springframework.core.io.Resource resource = new ClassPathResource(
filePath);
File file=resource.getFile();
2204
2250
952
742

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