java工程文件路径的问题

Posted 夏蝉冬雪

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java工程文件路径的问题相关的知识,希望对你有一定的参考价值。

String classpath = this.getClass().getResource("/").getPath().replaceFirst("/WEB-INF/classes/", "").replaceFirst("/", "");

 

String filePath=classpath+"/data/custNmList.xml";

 

D:/rw_pro_mars32/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/rwsN/src/main/webapp/data/custNmList.xml

 

原文

http://www.cnblogs.com/a757956132/p/4744675.html

 

好像properties文件必须放在根目录下,不然获取不到,然而springmvc的log4j.properties也没有放在根目录下

以上是关于java工程文件路径的问题的主要内容,如果未能解决你的问题,请参考以下文章