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.
hehe=sadfsdfsdfsdf
key1=中国
这是一个输出文件
#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();
}