Reading files from 10000 sub directories

I have to recursively read files from 10000 subdirectories. Each subdirectory might have 1000+ files. What would be the best way to read directories recursively ? Is there anything better than calling listFiles and then checking if it's a directory. I am planning to read 1000 files during one cycle.

[308 byte] By [mohitanchliaa] at [2007-11-27 11:18:33]
# 1

When you say read files you mean check there contents I take it? I think the only way it to traverse the directory as you mentioned. What will you be looking for? A string in a text file for instance?

_helloWorld_a at 2007-7-29 14:31:33 > top of Java-index,Java Essentials,Java Programming...
# 2

I need to read all those file and send it to other server for processing.

mohitanchliaa at 2007-7-29 14:31:33 > top of Java-index,Java Essentials,Java Programming...
# 3

Your hierarchy structure is nothing but a tree.

For example take this strucutre:

A

/ \

BC

/\ /\

/\/\

F GDE

Each node is a directory and the leaf node is file.

You can use Post Order Traversal. That is Left-Right-Root. You can select any traversal technique. All you have to do is check that each element you are currently handling is a leaf node or not.

qUesT_foR_knOwLeDgea at 2007-7-29 14:31:33 > top of Java-index,Java Essentials,Java Programming...