Jason
Jason

Reputation: 11

Taking tar -tf output and putting it into a java jtree

I want to take the output of a tar -tf which is a long directory listing for linux filesystem and put it into a java jtree.

The problem I am running into is how to get the hierarchy correct. The root node is easy but how do I add the other nodes to the tree in the proper place? I believe it would involve finding the parent node in the tree.

So far I am using DefaultMutableTreeNode as the root and creating a new one for each node. I created a custom object overriding toString to give the name of the directory or file, a getPath that returns the full path to it and getParent which is the full path without the name on the end.

Upvotes: 1

Views: 162

Answers (1)

trashgod
trashgod

Reputation: 205785

The article Understanding the TreeModel may offer some guidance on modeling hierarchical files in a TreeModel suitable for use with JTree.

Upvotes: 2

Related Questions