2021-09-20 IO流(Properties存取)

2021-10-11  本文已影响0人  Denholm
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));
        }

    }

}
上一篇下一篇

猜你喜欢

热点阅读