java读取项目中的文件

System.getProperty("user.dir")+"\\src\\main\\resources\\xxx.xml

此为项目中文件的路径。

System.getProperty("user.dir")得到的是当前项目的路径。比如D:\workspace\demo

还有一种:

InputStream in = GoodsPropertiesManager.class.getResourcesAsStream("XXX");

加载当前工程中的文件,比第一种更好用。

转载于:https://www.cnblogs.com/xu-thinking/p/3386619.html

猜你喜欢

转载自blog.csdn.net/weixin_34050519/article/details/93374812