Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JSP Tree Structure

843789Apr 8 2009 — edited Apr 8 2009
Hi,

I am struggling with the following problem. Can somebody pls help me?.

I have a file name and have a folder File f1= new File("path of the folder");. The folder is a complicated folder structure i.e. contains various files and sub folders which contains further subfolders etc. I want to show the whole folder structure(like tree structure). But, the following code shows only the "WebContent" structure.Please find below the following code:
File f1 = new File("D:/eclipse/workspace/cms/WebContent");
File[] contents = f1.listFiles();
for (int j=0; j<contents.length; j++) 
{
 
    if(contents[j].isDirectory())
    {
        out.println("Directory : "+contents[j].getName()+"<br/>");
    }
    else
    {
        out.println("Files :"+contents[j].getName()+"<br/>");
    }
 
}
If anybody knows the answer, please let me know....

Thanks in Advance,



V. Prasath
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 6 2009
Added on Apr 8 2009
2 comments
127 views