File testDirectory = new File("C://rootDir//");
File[] files = testDirectory.listFiles(new FilenameFilter()
{
@Override
public boolean accept(File dir, String name) {
return name.toLowerCase().endsWith(".xml");
}});
What is the problem with above code. You can use this for listing files by excluding subfolders.
FileFilter also do's same thing but it will be used when file name is not sufficent to listing the files. i.e if you want list all hidden files or readonly file etc. you can use FilteFilter