I'm recursively traversing a directory tree and for each node I call: exists(), isFile() and isDirectory().
Aside from using JNI,
you should be able to get some minor improvements just by skipping some of these calls as unnecessary. For example:
The listFiles() method shouldn't be giving you any file objects for things that don't exist, after all.
Some OS's may have other objects that aren't considered files
or directories. If so, you can go ahead and put in the directory check explicitly:
But you could also tell if something was really a directory by looking at the return value of listFiles(), as it will be null for any non-directory. So I might do something like this: