Two Laptop Bag*
The moose likes Java in General and the fly likes Java trees Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java trees" Watch "Java trees" New topic
Author

Java trees

Maha Hassan
Ranch Hand

Joined: Aug 02, 2005
Posts: 133
Hi,

I want to represent the hierarchy of folder using java (not GUI) so that I can print the top level in it and all the details.

Is there a way to do that in Java, or do I have to impalement my own tree??

Thanks,

Maha
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Class java.io.File represents a path to a file or directory. It contains methods to list the subdirectories and files in a directory.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Maha Hassan
Ranch Hand

Joined: Aug 02, 2005
Posts: 133
I mean, I am reading a certain hierarchy(not form a directory) and I want to represent it in a tree form.

Is there a thing like that?

Thanks.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
You can use the Tree classes from Swing even if you don't have a GUI. See if any implementation of TreeNode works for you, or make your own. If you get stuck, post some code and we'll try to bump you along.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Maha Hassan
Ranch Hand

Joined: Aug 02, 2005
Posts: 133
Thanks all for reply,

I used the implementations of binary tree to create my tree (not binary). I just removed the normal left and right children with array list to have more than one child

Thanks all.

Maha
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java trees
 
Similar Threads
how do I set all the values in a hashmap<String, Integer> to 0?
html to xhtml
Design Pattern
How to create password protected file
text field validations