spring 得到文件路径

引用
new ClassPathResource("mpos/mposBat.conf").getFile().getAbsolutePath()

String realPath = this.getClass().getClassLoader().getResource("").getPath();

两句相同效果


file:/C:/danny/code_base/20171031_mpos_bill/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MPayBill/WEB-INF/classes/mpos/mposBat.conf

C:\danny\code_base\20171031_mpos_bill\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\MPayBill\WEB-INF\classes\mpos\mposBat.conf

猜你喜欢

转载自dannyhz.iteye.com/blog/2401517
今日推荐