import java.util.Properties;
import java.util.Set;
public class PropertiesDemo {
public static void main(String[] args) {
setAndGet();
}
public static void setAndGet() {
Properties prop = new Properties();
prop.setProperty("zhangsan", "30");
prop.setProperty("lisi", "20");
System.out.println(prop);
String lisi = prop.getProperty("lisi");
System.out.println(lisi);
prop.setProperty("lisi", 89 + "");
Set<String> names = prop.stringPropertyNames();
for (String name : names) {
System.out.println(name + ": " + prop.getProperty(name));
}
}
}
网友评论