File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Listing the Files or Subdirectories in a Directory Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

Listing the Files or Subdirectories in a Directory

vivek gaur
Greenhorn

Joined: Dec 30, 2005
Posts: 21
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

Joined: Jan 30, 2000
Posts: 18670
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 ]

"I'm not back." - Bill Harding, Twister
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56191
    
  13

Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Listing the Files or Subdirectories in a Directory
 
Similar Threads
regex needed to find all files with no extension
JFileChooser
is it a bug or somethingelse?
batch file sample code
list the files or subdirectories ina directory