Java directory FAQ: How do I walk a directory tree and do something with the files and directories I find?
I was going to write an example here, but there are good examples in the DirectoryWalker API docs. The really short answer is (a) create your own class that extends the DirectoryWalker class, and (b) override the
handleDirectory methods of that class to do what you want with each file and directory.
The examples also show that you can do some really powerful things with standard FileFilters.