Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing / reading JTree to/from xml / html file

 
John Vorwald
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I need some help in writing / reading a jtree to a binary file and also to an html file.

A program uses a jtree to create / investigate structural modifications to an analytical model. As the program runs, the various perturbations of the analytical model are added to the tree, and the perturbations evaluated with summary performance results stored in the tree, and the more successful performing leafs are explored / expanded further. I need to write the jtree data to a file as additional leafs are added to the tree, and then read in a previously written tree when the program restarts.

I can probably implement a tree traversal and write out either a binary or text representation of the tree, but haven't done this before, so any suggestions on writing / reading a jtree to a file would be appreciated.

Also, it would be advantageous to write out an html file of the tree structure that could be viewed using a browser so the progress / solution could be investigated while the program continues to run.

Each leaf of the tree holds quite a bit of data that defines a model topology (inputs, outputs, model structure, number of submodels, etc) and also contains summary performance data of the submodels. The submodels of a leaf are essentially trivial variations of the leaf's model.

This program will run for a long time, think years, and essentially continuously evaluate / optimize the model structures as new data becomes available. There will probably be times when the evolution of the performance of optimal model structures is reviewed, so a "archival" copy of the current tree should be written out at some interval, like every two weeks, and also whenever model results are utilized (random intervals).
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the javax.swing.JTree JavaDocs, serializing a JTree is only recommended for short term use and points to java.beans.XMLEncoder for the preferred way of storage.

I would certainly look into XMLEncoder.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic