aspose file tools
The moose likes Beginning Java and the fly likes Listing files in directory (and subdirectory) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Listing files in directory (and subdirectory)" Watch "Listing files in directory (and subdirectory)" New topic
Author

Listing files in directory (and subdirectory)

Mark Runals
Greenhorn

Joined: Aug 15, 2007
Posts: 5
Hello all,

I have some code that will return file names over a certain character count. What I am trying to do is take that to the next level and have it crawl into subfolders of that directory as well. The problem is I end up with some Frankenstein code that in the end doesn't work. Below is the working, first level of the directory code. Any tips would be great.


[ September 28, 2007: Message edited by: Mark Runals ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35232
    
    7
What you need is a recursive method that can call itself as it descends into the directory tree. The general structure would be something like this:

[ September 28, 2007: Message edited by: Ulf Dittmer ]

Android appsImageJ pluginsJava web charts
Mark Runals
Greenhorn

Joined: Aug 15, 2007
Posts: 5
Sorry I should have been clearer. I understand I need to put in a recursive method. The issue I have is trying to take examples from the web and and modify them or create one myself and have it actually work - thus the Frankenstein code reference.
Mark Runals
Greenhorn

Joined: Aug 15, 2007
Posts: 5
For posterity here is what I came up with. Am sure there are better ways to do this.

 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Listing files in directory (and subdirectory)
 
Similar Threads
split a file to original files
File.isFile() and File.isDirectory() both return false
FTP with sun.net.ftp.
Copying one node to another node
File Listing