我有一个具有一些属性的对象配置。我可以导出这个,但是,它还有一个与嵌入类相关的 ArrayList,当我导出到 XML 时,我无法显示该类。任何指示都会有帮助。
导出方式
public String exportXML(config conf, String path) {
String success = "";
try {
FileOutputStream fstream = new FileOutputStream(path);
try {
XMLEncoder ostream = new XMLEncoder(fstream);
try {
ostream.writeObject(conf);
ostream.flush();
} finally {
ostream.close();
}
} finally {
fstream.close();
}
} catch (Exception ex) {
success = ex.getLocalizedMessage();
}
return success;
}
Run Code Online (Sandbox Code Playgroud)
配置类 (为了缩小尺寸而删除了一些细节)
public class config {
protected String author = "";
protected String website = "";
private ArrayList questions = new ArrayList(); …Run Code Online (Sandbox Code Playgroud)