向属性文件中添加属性

Posted on 2016-06-12 03:29  上善其若水,厚德载物  阅读(333)  评论(0编辑  收藏  举报
public static void main(String[] args) {
        saveProperties("aa","bb");
    }
    
    public static void saveProperties(String key,String value){
        Properties p = new Properties();
        p.setProperty(key, value);
        
        try {
            FileOutputStream out = new FileOutputStream("d:\\mess.properties");
            p.store(out, "test");
            out.close();
            
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        
        
        
    }

Copyright © 2024 上善其若水,厚德载物
Powered by .NET 8.0 on Kubernetes