【发布时间】:2016-08-31 14:04:47
【问题描述】:
我已经创建了一个属性文件并存储在根文件夹中。 (java Web 项目,servlet)
代码:
Properties prop = new Properties();
try {
prop.setProperty("EPU", "A1,A2,A3,A4,A8,A9,B1,B2,B3,B8,B9");
//save properties to project root folder
prop.store(new FileOutputStream("dbsc.properties"), null);
} catch (IOException ex) {
}
并且在下面的路径中成功创建了属性文件
Project ->Project Name ->dbsc.properties
然后我想读取(加载)这个属性文件,下面的代码
prop.load(new FileInputStream("dbsc.properties"));
当我执行时收到 FileNotFoundException
java.io.FileNotFoundException: kindcode.properties (The system cannot find the file specified)
我的问题:
属性文件的保存过程和路径是否正确?
如何加载属性文件?
【问题讨论】:
标签: java servlets properties-file