views:

138

answers:

1

Hey everyone I'm trying to get a List of directories. I'm using FileUtils listFiles().

I want to do something like this: listFiles(File,IOFileFilter,false). My real questions is how I can implement the accept() from the IOFileFilter so I can check if current File is a directory?

Thank you in advance.

+4  A: 

File has an isDirectory() method you can call, so:

final IOFileFilter dirs = new IOFileFilter() {
    public boolean accept(File file) {
        return file.isDirectory();
    }
}

final IOFileFilter none = new IOFileFilter() {
    public boolean accept(File file) {return false;}
};

listFiles(file, dirs, none);
Michael Mrozek
Yes thank you that was exactly what I was looking for. I know File has isDirectory(). It's just me that I like the other way better.
Marquinio