Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

generate a tree structure

 
Pravin Shirke
Ranch Hand
Posts: 152
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,
i want to generate the tree structure of directory. e.g. if directory is home and it has many sub directory i want to display all the sub-directories in a directory and so on till all are display. i am able to find out the directory. but the problem is how should i trace in until the last directory in a directory. like home/a/b/c/d..... until all the directories are exhausted.
 
Piyush Porwal
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think recursively
Just consider one level at a time. Display contents of a node and then (recursively) for all its children (sub-dir) call this same method.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you asking about a web GUI or a Java GUI?
 
Pravin Shirke
Ranch Hand
Posts: 152
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ulf,
i am using java GUI Swings API for that.
 
Piet Verdriet
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pravin shirke wrote:hi ulf,
i am using java GUI Swings API for that.


Have a look at this article:
http://java.sun.com/products/jfc/tsc/articles/treetable1/index.html
and/or:
http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic