Please
use code tags in the future. I added some to your previous post for you.
The code you show wouldn't have any output. Do you mean you uncommented the System.out.println()? Was there some output, just very slow? Or was there
no output, despite a long wait?
Unfortunately, list() and listFiles() can be very slow on some machines if the directory is very large. Now that I think about it, you
might get faster results here using list() instead, though I doubt it. Maybe
you should try it though. Anyway, there's not a lot you can do to speed this up unless you're willing to do some platform-specific stuff. Try using the command line to list the contents of this huge directory, and comparing this to the time it takes to call File.ListFiles() or File.list() in the same directory. Is the command line much faster than list()? If not, then the problem is probably with your underlying system, and changing your program is unlikely to help you. But if the command line is much faster, then you might want to use Runtime.exec() to do the directory listing - then read lines from the InputStream of the Process object which the exec() returns. Each line would be the name of one of the files or subdirectories. This is inelegant, but if the command line is much faster than list(), this will allow you to improve performance on that particular system at least.
You could also use JNI to call a C method. I haven't used JNI in ages, and my experience is that using exec() will probably be easier.
Hope that helps...
[ January 06, 2006: Message edited by: Jim Yingst ]