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