用Properties的store方法
修改后的Properties prop
prop.store(new FileOutputStream("你原来的文件“));

解决方案 »

  1.   

    何必要写这个文件呢,不如在这个文件中记一个XML文件的路径,然后去写那个XML就可以了
      

  2.   

    巨同意zebero 一般都是用Properties的store方法做的
      

  3.   

    楼上的两位兄弟,有没有相关的例子啊.
    这个store(OutputStream,String)的用法是怎么样的.
    我也想过要这样子用的.但是它要用到OutputStream对象的
    有没有详细一点的例子说明啊.我刚学的,没有用过这些对象!!
    谢谢了
      

  4.   

    InputStream is=null;
    is=getClass().getResourceAsStream("/db.properties");
    prop.store(is);
      

  5.   

    to:  zebero(long) 
    你的方法我试过了.还是不行!!
    你说的原来的文件.包括路径吗.
    is=getClass().getResourceAsStream("/db.properties");
    这是打开的文件路径.保存也是这个路径吗.我用这个路径不行!
      

  6.   

    to: moumouren(某某人) 你说的是什么意思??
    prop.store(is).
    这个is是InputStream对象啊!!
    store需要的是OutputStream对象!
    能不能说清楚点啊.最好有代码.
    谢谢了.
      

  7.   

    String fileName = "/aaa.properties";                        
    InputStream is=null;                                        
    is=getClass().getResourceAsStream(fileName);                
    Properties prop=new Properties();                           
    prop.load(is);                                              
    prop.setProperty("key", "value");                           
    URL url = getClass().getResource(fileName);                 
    FileOutputStream fos = new FileOutputStream(url.getPath()); 
    prop.store(fos,"");                                         
    fos.flush();                                                
    fos.close();                                                
      

  8.   

    to:moumouren(某某人)这个方法是可以写进去东西:)
    但是写进去的是乱码.是不是需要转化啊?
    怎么样转化,能不能给个例子看看:)
    谢谢了.
    搞定了就给分
      

  9.   

    你参考一下他的帮助类,存储的方法只有两个,store()与save()
    你试一下,具体原代码我忘了。