File f=new File("D:\\myfile.text");
Properties pp=new Properties(); pp.setProperty("001","I am a student!");
pp.setProperty("002","Me too!");

try {
FileOutputStream out = new FileOutputStream(f,true);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
pp.store(out,"test");

解决方案 »

  1.   

    是out访问不到.
    应该改成
    FileOutputStream out = null;
    try
    {
      FileOutputStream out = new FileOutputStream(f,true); 

    catch (FileNotFoundException e1) 

    e1.printStackTrace(); 

    pp.store(out,"test");
      

  2.   

    你的FileOutputStream out = new FileOutputStream(f,true);这句代码放在了try里面,他的作用域只局限在try中,超出这个范围就不可见了,所以pp.store(out,"test")这句会提示out没有定义。
      

  3.   

    问一下lz pp.store(out,"test2"); 这一句中“test2”参数代表什么意思呀( store的具体用法) ?