You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Mark A Fortner <ph...@yahoo.com> on 2006/12/05 23:02:29 UTC

[VFS] Find Files Method Problem

I've been having problems implementing a simple FileSelector.  My goal is to find all children of a given FileObject whose extension is "xyz".  Here's what I've got:

FileObject files[] = fo.findFiles(new FileDepthSelector(1,1)
        {
            public boolean includeFile(FileSelectInfo fileInfo){
                FileObject fo = fileInfo.getFile();
                return (fo.getName().getExtension().equalsIgnoreCase(ext));
            }

           
        });

When I add the code below, it throws an exception indicating that the list of files is null.

        if (files == null || files.length == 0){
            throw new FileSystemException("Unable to find file with extension: " + ext);
        }

When I debug this, it shows that the FileSelectInfo is actually looking at the parent and not at the children.  According to the documentation the findFiles method is supposed to return all of the children, but I don't see how it does this if the FileSelectInfo object that it uses always points to the parent.

I've also tried creating my own FileSelector but it has the same results.

Does anyone have any ideas?

Mark