我想将属性文件存储为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)