首页 > 编程语言 > 详细

Java读写properties配置文件

时间:2016-02-07 02:13:25      阅读:138      评论:0      收藏:0      [点我收藏+]

File in = new File("src" + File.separator + "conf.properties");
Properties properties = new Properties();
properties.load(new FileInputStream(in));

 

System.out.println(properties.getProperty("user"));

 

以下是properties内容:

user=admin
passwd=123

File out = new File("conf2.properties");
properties.setProperty("k", "v");
properties.store(new FileOutputStream(out), "写备注");

xml

File in = new File("conf.xml");
Properties properties = new Properties();
properties.loadFromXML(new FileInputStream(in));

Java读写properties配置文件

原文:http://www.cnblogs.com/sysout/p/5184341.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!