java - Convert File Hierarchy to MutableTreeNode in Jtree -


i have hierarchy of file structure in java.. how convert defaultmutabletreenode heirarchy. tried fetching each file individually, checked each if directory or not, did recursive loop , formed file structure. now, convert defaultmutabletreenode, have utilities or again need top-down approach check , convert them again node-by-node.?

do have utilities such already?

need suggestions!

there no built-in utilities create jtree model filesystem snippet. there file chooser if after. otherwise approach seems reasonable me. convert files defaultmutabletreenode in 1 pass. like:

public class filenode extends defaultmutabletreenode {   private file file;    public filewrapper(file file) {     super(this);     this.file = file;     if(file.isdirectory()) {       for(file file : listfiles) {         add(new filenode(file));       }     }   }    private string tostring() {     return file.getname();   }    private file getfile() {     return file;   }  } 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -