项长老

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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));

posted on 2016-02-06 23:58  项长老  阅读(178)  评论(0编辑  收藏  举报