java解析.properties的配置文件
admin 发布于:2009-07-20 22:57:00
阅读:loading
db.properties
driver:com.microsoft.jdbc.sqlserver.SQLServerDriver##这里的dirver:也可以换成是=,如果是=的话,后面又有:就得用\转义
url:jdbc:microsoft:sqlserver://localhost:1433;
username:sa
password:
***********************************************************************
public void getFile(String fileName) {
Properties prop = new Properties();
InputStream in = getClass().getResourceAsStream(fileName);
if (in != null)
try {
prop.load(in);
} catch (IOException e) {
e.printStackTrace();
} finally {
in.close();
}
System.out.println(prop.getProperty("driver"));
System.out.println(prop.getProperty("url"));
System.out.println(prop.getProperty("username"));
System.out.println(prop.getProperty("password"));
}
注
上述许多内容已经过时和过期了,留存本篇文章仅为方便个人查看,原始文章的信息参考:
原始链接:hhttps://www.chendd.cn/information/viewInformation/other/16.a
最后更新:2009-07-20 22:57:00
访问次数:188
评论次数:0
点赞个数:0
点赞