小编use*_*084的帖子

如何使用排序键将java.util.Properties写入XML?

我想将属性文件存储为XML.有没有办法在执行此操作时对键进行排序,以便生成的XML文件按字母顺序排列?

String propFile = "/path/to/file";
Properties props = new Properties();
/*set some properties here*/
try {
    FileOutputStream xmlStream = new FileOutputStream(propFile);
    /*this comes out unsorted*/
    props.storeToXML(xmlStream,"");
} catch (IOException e) {
    e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

java xml

13
推荐指数
2
解决办法
2万
查看次数

标签 统计

java ×1

xml ×1