package com.soar.otherio;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;
public class Demo10_Properties {
public static void main(String[] args) throws IOException {
Properties prop = new Properties();
prop.load(new FileInputStream("config.properties"));
prop.setProperty("tel","112110189875");
prop.store(new FileOutputStream("config.properties"),null);
System.out.println(prop);
}
private static void demo2() {
Properties prop = new Properties();
prop.setProperty("tel","18888888888");
prop.setProperty("name","张三");
Enumeration<String> en = (Enumeration<String>) prop.propertyNames();
while((en.hasMoreElements())){
String key = en.nextElement();
String value = prop.getProperty(key);
System.out.println(key + "=" + value);
}
}
private static void demo1() {
Properties prop = new Properties();
prop.put("abc", 123);
System.out.println(prop);
}
}