Listing the Files or Subdirectories in a Directory
Joined: Dec 30, 2005
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.
Joined: Jan 30, 2000
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 ]