I have a method that should write object to XML file
public void save(OutputStream os) {
XMLEncoder e = new XMLEncoder(new BufferedOutputStream(os));
e.writeObject(this);
e.flush();
e.close();
}
This class have 4 fields
final static public String EOL = System.getProperty("line.separator");
final public static String DEF_FILE_NAME = "security.conf";
private Map<String, String> users = new HashMap<>();
private String logKey;
and many methods, one of methods is save(OutputStream os)
presented above.
But XMLEncoder write only this
<?xml version="1.0" encoding="UTF-8"?>
<java version="1.7.0_80" class="java.beans.XMLDecoder">
</java>
What can be wrong?
I have solved it. Problem was in constructor. Class must have public constructor with no parameters.