• Post Reply Bookmark Topic Watch Topic
  • New Topic

Files

 
sai challa
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a root directory a ,some directories b,c,d under it,which in turn contain some more sub-directories under them and so on.Could anybody suggest me a method where i could get all the files present in directory b or c or d including the files in their sub-dirs
[This message has been edited by sai challa (edited April 13, 2001).]
 
Phil Hanna
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Create a java.io.File object from the directory
2. Call its list() method to get a list of file names
3. Create file objects out of each one. If they are directories, call the whole thing recursively.


------------------
Phil Hanna
Author of :
JSP: The Complete Reference
Instant Java Servlets
 
sai challa
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Phil .This code helped a lot.
 
Amit Roy
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This will give me all the directories below the root directory wat if i want all the directories above the root directory also
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!