Easier is to realise that the File object has an isDirectory method, which would seem as if it were written to answer this very question:
File testDirectory = new File("C://rootDir//");
File[] files = testDirectory.listFiles();
for (File file : files) {
if ( (file.isDirectory() == false) && (file.getAbsolutePath().endsWith(".xml") ) {
// do what you want
}
}