K
Kaidi
Hello all,
I have a class, which contains "pointers" so that it can construct a
tree like data structure (actually, I use it to store the tag tree I
built from a HTML file).
The problem is: how to save / load this class?
==== The class looks like: ==========
public class TagTreeNode implements Serializable {
//
private
String stringValue;
private
int nodeID;
private
int level;
private
String tagString;
private
TagTreeNode previousSibling;
private
TagTreeNode nextSibling;
private
TagTreeNode firstChild;
private
TagTreeNode parentNode;
//
// other functions etc.
}
========
Currently, I build a tree structure in which each node is of above
class.
I have the root node called rootNode.
And I try to save the whole tree using the following code:
==============
File thefile = new File(filename);
FileOutputStream fout = new FileOutputStream(thefile);
ObjectOutputStream oos = new ObjectOutputStream(fout);
oos.writeObject(rootNode);
oos.close();
fout.close();
=======
This works fine for smaller trees. For biggers trees (actually, not so
big, only about 1000 - 2000 nodes in the tree, built from a HTML file
of 110K size), I always get the java.lang.StackOverflowError error.
PS: I have tried these: -Xss200M -Xmx200M -mx200M -Xms200M, seems no
use.
Any one can tell me either:
how to avoid the error?
or
how can I (in a good manner) save such a tree data structure onto file
? (and load it later)
Thanks a lot and have a great holiday!~
I have a class, which contains "pointers" so that it can construct a
tree like data structure (actually, I use it to store the tag tree I
built from a HTML file).
The problem is: how to save / load this class?
==== The class looks like: ==========
public class TagTreeNode implements Serializable {
//
private
String stringValue;
private
int nodeID;
private
int level;
private
String tagString;
private
TagTreeNode previousSibling;
private
TagTreeNode nextSibling;
private
TagTreeNode firstChild;
private
TagTreeNode parentNode;
//
// other functions etc.
}
========
Currently, I build a tree structure in which each node is of above
class.
I have the root node called rootNode.
And I try to save the whole tree using the following code:
==============
File thefile = new File(filename);
FileOutputStream fout = new FileOutputStream(thefile);
ObjectOutputStream oos = new ObjectOutputStream(fout);
oos.writeObject(rootNode);
oos.close();
fout.close();
=======
This works fine for smaller trees. For biggers trees (actually, not so
big, only about 1000 - 2000 nodes in the tree, built from a HTML file
of 110K size), I always get the java.lang.StackOverflowError error.
PS: I have tried these: -Xss200M -Xmx200M -mx200M -Xms200M, seems no
use.
Any one can tell me either:
how to avoid the error?
or
how can I (in a good manner) save such a tree data structure onto file
? (and load it later)
Thanks a lot and have a great holiday!~