Java properties | FileNotFoundException: properties (系统找不到指定的文件。)
2015-03-21 12:26
661 查看
文件存储路径的问题
错误描述 :FileNotFoundException: init.properties (系统找不到指定的文件。)
1.方法一
InputStream fis =TestProperties.class.getClassLoader().getResourceAsStream("init.properties")
2.方法二(要求TestProperties和init.properties在同一目录下)
InputStream fis =TestProperties.class
.getResourceAsStream("init.properties")
推荐使用2。 放在TestProperties.java同级目录下面
3.方法三,对于Web工程也可以这样。
先获取ServletContext,然后
InputStream in=context.getResourceAsStream("/WEB-INF/classes/init.properties");
文件存储路径的问题
错误描述 :FileNotFoundException: init.properties (系统找不到指定的文件。)
1.方法一
InputStream fis =TestProperties.class.getClassLoader().getResourceAsStream("init.properties")
2.方法二(要求TestProperties和init.properties在同一目录下)
InputStream fis =TestProperties.class
.getResourceAsStream("init.properties")
推荐使用2。 放在TestProperties.java同级目录下面
3.方法三,对于Web工程也可以这样。
先获取ServletContext,然后
InputStream in=context.getResourceAsStream("/WEB-INF/classes/init.properties");
相关文章推荐
- nested exception is java.io.FileNotFoundException: config.xml (系统找不到指定的文件。)
- Java项目读取配置文件时,FileNotFoundException 系统找不到指定的文件,System.getProperty("user.dir")的理解
- Error:java.io.FileNotFoundException: 系统找不到指定的文件.
- 如何解决java.io.FileNotFoundException: mysql.ini (系统找不到指定的文件。)
- java.io.FileNotFoundException关于使用Intellij Idea时系统找不到指定文件的解决方案
- 服务 在初始化安装时发生异常:System.IO.FileNotFoundException: "file:///D:\testService"未能加载文件或程序集。系统找不到指定文件。
- java.io.FileNotFoundException: .\xxx\xxx.png (系统找不到指定的路径。)
- Android 混淆提示 java.io.FileNotFoundException: ...\proguard-rules\release\aapt_rules.txt (系统找不到指定的路径)
- java.io.FileNotFoundException: D:\workspace\gbrm\WebRoot\空缺职位列表20140414093026.xls (系统找不到指定的路径。)
- 【已解决】Windows Service 问题System.IO.FileNotFoundException: 未能加载文件或程序集“file:///”或它 的某一个依赖项。系统找不到指定的文件。。
- 解决 System.IO.FileNotFoundException: 未能加载文件或程序集“Team.DLinqDAL”或它的某一个依赖项。系统找不到指定的文件。
- System.IO.FileNotFoundException:“未能加载文件或程序集“xxx”或它的某一个依赖项。系统找不到指定的文件。”
- Android 混淆提示 java.io.FileNotFoundException: ...\proguard-rules\release\aapt_rules.txt (系统找不到指定的路径)
- java.io.FileNotFoundException: D:\Workspaces\MyEclipse 8.5\spring\applicationContext.xml (系统找不到指定的文
- java.io.FileNotFoundException问题,说是db.properties文件找不到,但是在webapps里存在的
- log4j:ERROR setFile(null,true) call failed.java.io.FileNotFoundException: ..\logs\2010-1-19.log (系统找不到指定的路径。)
- Log4J配置后, log4j:ERROR setFile(null,true) call failed. 报错:java.io.FileNotFoundException: /log/mytest2.log (系统找不到指定的路径。)
- java.io.FileNotFoundException问题,说是db.properties文件找
- eclipse写了个JDBC程序却找不到文件却抛出java.io.FileNotFoundException 文件找不到错误
- 启动tomcat时报错java.io.FileNotFoundException (系统找不到指定的路径。)