public class hello {
public static void main(String[] args) throws Exception
{
//创建集合
Properties properties=new Properties();
//添加数据
properties.setProperty("xiao", "456");
properties.setProperty("jsag","afsg");
System.out.println(properties.toString());
//遍历
// Set str=properties.keySet();
// System.out.println(str);
Set<String> buf=properties.stringPropertyNames();
for (String pro : buf) {
System.out.println(pro+"--"+properties.getProperty(pro));
}
//-------list方法 列表--------
PrintWriter pw=new PrintWriter("e:\\print.txt");
properties.list(pw);
pw.close();
//-------store方法 保存--------
FileOutputStream fos=new FileOutputStream("e:\\store.properties");
properties.store(fos, "注释");
fos.close();
//-------load方法 加载--------
Properties properties2=new Properties();
FileInputStream fis=new FileInputStream("e:\\store.properties");
properties.load(fis);
fis.close();
System.out.println(properties2.toString());
}
}