你的FileOutputStream 怎么没有关闭呢?

解决方案 »

  1.   

    谢谢,关闭了也一样的啊,能读出数据,但还是保存不了,不会跟属性内容有关吧,我里面就有
    hehe=sadfsdfsdfsdf
    key1=中国
      

  2.   

    Because Properties inherits from Hashtable, the put and putAll methods can be applied to a Properties object. Their use is strongly discouraged as they allow the caller to insert entries whose keys or values are not Strings. The setProperty method should be used instead. If the store or save method is called on a "compromised" Properties object that contains a non-String key or value, the call will fail. When saving properties to a stream or loading them from a stream, the ISO 8859-1 character encoding is used. For characters that cannot be directly represented in this encoding, Unicode escapes are used; however, only a single 'u' character is allowed in an escape sequence. The native2ascii tool can be used to convert property files to and from other character encodings. 
      

  3.   

    我试了你这个问题,没有问题的。
    这是一个输出文件
    #Welcome,Welcome!!!
    #Tue Nov 02 12:53:37 CST 2004
    key2=\u4E3A\u4EC0\u4E48\u82B1\u513F\u8FD9\u6837\u7EA2\uFF1F
    hehe=sadfsdfsdfsdf
    key1=\u4E3A\u4EC0\u4E48\u82B1\u513F\u8FD9\u6837\u7EA2\uFF1F因为你的输入文件和输入文件都是一样的,如果运行了一次这个文件之后,下一次在读取的时候就会出问题,会抛出 NullPointerException 或者 NoSuchElementException因为你下面这段代码把捕捉到的 Exception 隐藏了,所以你得不到
                } catch (Exception e) {
                }
    改成这样,就知道了
                } catch (Exception e) {
                    e.printStackTrace();
                }
      

  4.   

    jamesfancy()边城狂人(James Fancy) 说得没错,是我程序有点问题,现在能更新文件了,但属性文件内容已经被转换过了,我想让它保存为中文的,谢谢