Listing only files in directory

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
    }
}

Use a FileFilter instead, as it will give you access to the actual file, then include a check for File#isFile

File testDirectory = new File("C://rootDir//");
File[] files = testDirectory.listFiles(new FileFilter() {
    @Override
    public boolean accept(File pathname) {
        String name = pathname.getName().toLowerCase();
        return name.endsWith(".xml") && pathname.isFile();
    }
});