Use the listFiles() method of the File class to iterate through all the files in a directory. The isDirectory() method can be used to determine which are directories.
public static void traverse(File directory)
{
// Get all files in directory
File[] files = directory.listFiles();
for (File file : files)
{
if (file.isDirectory())
{
// Its a directory so (recursively) traverse it
traverse(file);
}
else
{
// its a file, do any processing you require here
}
}
}