根据文件路径和文件名获取文件File---(项目目录)(本地)下的文件

如下获取的是WebContent下的upload里面的error.xml

String classpath = this.getClass().getResource("/").getPath();
String savedir = classpath.replaceAll("WEB-INF/classes/", "") + "upload/";
filename=savedir+"error.xml";
File file = new File(filename);

猜你喜欢

转载自www.cnblogs.com/fengnan/p/10000552.html