properties文件读取不到第一行数据
properties文件注意事项
Properties类API(http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html)中提到如下一句话
The load(Reader) / store(Writer, String) methods load and store properties from and to a character based stream in a simple line-oriented format specified below. The load(InputStream) / store(OutputStream, String) methods work the same way as the load(Reader)/store(Writer, String) pair, except the input/output stream is encoded in ISO 8859-1 character encoding. Characters that cannot be directly represented in this encoding can be written using Unicode escapes as defined in section 3.3 of The Java™ Language Specification; 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.
大体意思是, properties文件是基于行来读取和存储键值对的, 而期望的输入/输出流字符编码是ISO 8859-1. 那些不能使用该方式存储的字符集呢, 需要使用native2ascii命令对property文件进行转码.
解决方案一:
仍然使用UTF-8编码方式, 将第一行给空出来
解决方案二:
按照API上的指示, 使用ISO 8859-1的编码方式存储properties文件, 中文用/u开头的unicode方式保存