spring get the file path

quote
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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326271973&siteId=291194637