美文网首页
2021-09-20 IO流(Properties存取)

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

作者: Denholm | 来源:发表于2021-10-11 19:36 被阅读0次
    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));
            }
    
        }
    
    }
    

    相关文章

      网友评论

          本文标题:2021-09-20 IO流(Properties存取)

          本文链接:https://www.haomeiwen.com/subject/hucvgltx.html