AKZ*_*Zap 4 java properties classpath
我在包的包下创建属性文件 resources/common/configure/
然后我创建代码
Properties prop = new Properties();
try {
//load a properties file
prop.load(new FileInputStream("resources/common/configure/commonData.properties"));
//get the property value and print it out
System.out.println(prop.getProperty("id"));
} catch (IOException ex) {
ex.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
但我得到以下错误
java.io.FileNotFoundException: (The system cannot find the path specified)
Run Code Online (Sandbox Code Playgroud)
请让我知道如何获得此属性文件.
试试吧
prop.load(getClass().getResourceAsStream("resources/common/configure/commonData.properties"));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16426 次 |
| 最近记录: |