Vij*_*yan 18 java eclipse properties
我之前使用Unix来编译和编辑我的Java.我已经在我当前工作目录中使用了属性文件,其中存在类文件.现在我已切换到Eclipse IDE.我不知道如何在Eclipse中添加相同的属性文件.请帮我.
Kha*_*bib 28
/ Java Resources/resources/config.properties
用于加载属性.
Properties prop = new Properties();
InputStream input = null;
try {
input = getClass().getClassLoader().getResourceAsStream("config.properties");
// load a properties file
prop.load(input);
// get the property value and print it out
System.out.println(prop.getProperty("database"));
System.out.println(prop.getProperty("dbuser"));
System.out.println(prop.getProperty("dbpassword"));
} catch (IOException ex) {
ex.printStackTrace();
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
123093 次 |
| 最近记录: |