设为首页 加入收藏

TOP

java读取properties文件(二)
2014-11-24 01:35:01 来源: 作者: 【 】 浏览:24
Tags:java 读取 properties 文件
oundException e) …{
e.printStackTrace();
} catch (IOException ioe)…{
ioe.printStackTrace();
}
}//end saveFile(…)


public static void main(String[] args)
…{
Configuration rc = new Configuration(“.\config\test.properties”);//相对路径


String ip = rc.getValue(“ipp”);//以下读取properties文件的值
String host = rc.getValue(“host”);
String tab = rc.getValue(“tab”);


System.out.println(“ip = ” + ip + “ip-test leng = ” + “ip-test”.length());//以下输出properties读出的值
System.out.println(“ip’s length = ” + ip.length());
System.out.println(“host = ” + host);
System.out.println(“tab = ” + tab);


Configuration cf = new Configuration();
String ipp = cf.getValue(“.\config\test.properties”, “ip”);
System.out.println(“ipp = ” + ipp);
// cf.clear();
cf.setValue(“min”, “999″);
cf.setValue(“max”, “1000″);
cf.saveFile(“.\config\save.perperties”, “test”);


// Configuration saveCf = new Configuration();
// saveCf.setValue(“min”, “10″);
// saveCf.setValue(“max”, “1000″);
// saveCf.saveFile(“.\config\save.perperties”);


}//end main()


}//end class ReadConfigInfo


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇广州-迈达威维佳.net 下一篇java开发人员面试总结。

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: