سؤال

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

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top