AllFileSelector. How exclude the current directory

175 views Asked by At

With this lines I'm get a list with all files under but also the current directory

List<FileObject> fileList = new ArrayList<FileObject>();
FileObject fileObject = ...
fileObject.findFiles(new AllFileSelector(), depthwise, fileList);

the list content it:

/foo/boo/bla.jpg
/foo/tal.jpg
/foo/cheese.jpg
/foo

and I want to get just this:

/foo/boo/bla.jpg
/foo/tal.jpg
/foo/cheese.jpg

have I set something in the selector?

thanks

1

There are 1 answers

0
René Link On BEST ANSWER

Use the FileTypeSelector or implement your own FileSelector.

fileObject.findFiles(new FileTypeSelector(FileType.FILE), depthwise, fileList);

This example will only select files and not directories. This might be sufficient for your current problem, but if you want to filter files based on their extension, e.g. ".png", then you must implement your own org.apache.commons.vfs2.FileFilter and use a FileFilterSelector.