package ming;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.util.Properties;public class PropertiesTest { /** * @param args * @throws IOException * @throws FileNotFoundException */ public static void main(String[] args) throws FileNotFoundException, IOException { // TODO Auto-generated method stub Properties props = new Properties(); //向Properties添加属性 props.setProperty("username", "abc"); props.setProperty("password", "123"); //保存到a.ini文件中 props.store(new FileOutputStream("a.ini"), "comment line"); //追加数据 Properties props2 = new Properties(); props2.setProperty("gender", "male"); props2.load(new FileInputStream("a.ini")); System.out.println(props2); }}