this makes it happen: i got it!
Thanks.
Michael Weller
----- Original Message -----
From: "Matthias Carlsson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 26, 2001 7:44 PM
Subject: SV: Print out directory structure
I'm just writing this down now, so it may not work out-of-the-box, but I
hope
you get the general idea.
public void printDirTree(File file, int level) {
File[] files = file.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
System.out.println("Found dir name " +
files.getName() + " (level: " +
level + ")");
printDirTree(files[i], level + 1);
}
}
}
And then, somewhere in the code, call this method with the base directory as
a File object, and with level of 0 or something.
printDirTree(new File("/"), 0);
Hope this helps.
[ Matthias Carlsson ]
[ Programmer (Java, XML/XSL, CGI/Perl, HTML/JS) ] [ Web Designer ]
[ E-Mail : [EMAIL PROTECTED] ] [ ICQ: 1430647 ]
> -----Ursprungligt meddelande-----
> Från: A mailing list for discussion about Sun Microsystem's Java Servlet
> API Technology. [mailto:[EMAIL PROTECTED]]För Michael Weller
> Skickat: den 26 februari 2001 15:53
> Till: [EMAIL PROTECTED]
> Ämne: Print out directory structure
>
>
> Hi everybody!
>
> Does anybody have a method that puts out the structure of the directories
> that are subdirectory of a specified directory (sounds a bit strange).
> Here's an example to clarify what I want:
>
> Specified Directory: docs
>
> Output of the servlet:
>
> docs
> - HTML
> - - SelfHTML
> - - HTML 4.0
> - Java
> - - Specifications
> - - - jai
> - - javadocs
> - - - servlet-api
> - - - jdk1.3 docs
> ...
>
> Hope anybody can help me!
>
> Michael Weller
>
> __________________________________________________________________
> _________
> To unsubscribe, send email to [EMAIL PROTECTED] and include
> in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html