If I encode a class with java.beans.XMLEncoder (Java 1.6) like the following:
fileOutputStream = new FileOutputStream(someFile);
XMLEncoder xmlEncoder = new XMLEncoder(fileOutputStream);
xmlEncoder.writeObject(anyObject);
xmlEncoder.close();
the result that is written to someFile
has a different element ordering when I run it on a different physical machine (also with Java 1.6).
Is there any guarantee on the ordering of fields of an object that is encoded by XMLEncoder
?
If not, how can I enforce an ordering which is the same each time an object is xml-encoded?