您的位置:首页 > 其它

间接获取Web项目中文件的绝对路径

2016-10-19 20:00 162 查看
@Test
public void testClassPathResource() throws IOException{
//filePath为web项目根目录下的文件
String filePath="metadata/questions.xlsx";
ClassPathResource resource = new ClassPathResource(filePath);
System.out.println(resource);
//通过getFile()获取该文件在本地的绝对路径
System.out.println(resource.getFile());

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  web