How could I serialize Enumeration object to a file and then deserialize it? I tried to convert it to ArrayList but this option doesn’t work for me. I tried the following code:
FileOutputStream fos = null;
ObjectOutputStream outs = null;
Enumeration<TreePath> stateEnum = com.jidesoft.tree.TreeUtils.saveExpansionStateByTreePath(tree);
ArrayList<TreePath> pathList = new ArrayList<TreePath>();
while(stateEnum.hasMoreElements()){
pathList.add(stateEnum.nextElement());
}
try {
fos = new FileOutputStream(TREE_STATE_FILE);
outs = new ObjectOutputStream(fos);
outs.writeObject(pathList);
outs.close();
} catch (IOException e) {
_log.info("Failed to create " + TREE_STATE_FILE + " file: ", e);
}
But when I tried to serialize it I get nulls.
Thanks
Im not sure if this what you mean but take a look at this code:
From here