当在Myeclipse中使用Properties类创建properties文件时,若使用storeToXML方法则文件后缀名必须为*.xml,否则会出现键值缺失的状况。如:
文件格式为properties时:
<?xml
version="1.0" encoding="UTF-8" standalone="no"?>
version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties>
<comment>gg</comment>
<entry key\="a">1</entry>
</properties>文件格式为xml时:<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties>
<comment>gg</comment>
<entry key="b">2</entry>
<entry key="a">1</entry>
</properties>猜想:在IDE内创建文件时,IDE可能会根据文件格式的规则来创建文件,导致格式不符的情况下数据丢失。而在外部创建时则不会。注意:上述情况只发生在Myeclipse内部中,若文件创建在非工作空间路径时则不会发生上述情况。至于Eclipse中是否会发生此种状况尚未验证。