Bookmark Topic Watch Topic
  • New Topic

Listing the Files or Subdirectories in a Directory  RSS feed

 
vivek gaur
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Report post to moderator
i am trying hard for this .
please anyone help me out.
i want to list the Files or Subdirectories in a Directory upto the bottom most level without even missing a single directory or even a file from the path that i give.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Report post to moderator
Are you aware of the File class, and the listFiles() method? That would be a good place to start. Unfortunately that method does not list the contents of subdirectories. So: are you familiar with the idea of recursive methods? Have you ever written a recursive method? It's possible to write a fairly straightforward recursive method which lists the contents of all subdirectories. Or, you could just look at something like org.apache.commons.io.FileUtils, specifically the listFiles() methods. But really, writing your own recursive listFiles() method is probably more rewarding. If it seems difficult, it's probable a worthwhile excercise to learn from. If you get suck, we can help you through the details if you show us what you're trying so far. Good luck.
[ April 08, 2006: Message edited by: Jim Yingst ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66304
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!