Example usage for org.apache.commons.vfs FileObject findFiles

List of usage examples for org.apache.commons.vfs FileObject findFiles

Introduction

In this page you can find the example usage for org.apache.commons.vfs FileObject findFiles.

Prototype

public void findFiles(FileSelector selector, boolean depthwise, List selected) throws FileSystemException;

Source Link

Document

Finds the set of matching descendents of this file.

Usage

From source file:org.codehaus.mojo.unix.util.vfs.IncludeExcludeTest.java

public void testBasic() throws Exception {
    String myProjectPath = new TestUtil(this).getTestPath("src/test/resources/my-project");

    FileSystemManager fsManager = VFS.getManager();
    FileObject myProject = fsManager.resolveFile(myProjectPath);

    assertEquals(FileType.FOLDER, myProject.getType());

    List<FileObject> selection = new ArrayList<FileObject>();
    myProject.findFiles(IncludeExcludeFileSelector.build(myProject.getName())
            .addInclude(new PathExpression("/src/main/unix/files/**")).addInclude(new PathExpression("*.java"))
            .addExclude(new PathExpression("**/huge-file")).filesOnly().
            //            noDefaultExcludes().
            create(), true, selection);/*ww w. j a  v  a  2 s  .co  m*/

    System.out.println("Included:");
    for (FileObject fileObject : selection) {
        System.out.println(myProject.getName().getRelativeName(fileObject.getName()));
    }

    assertEquals(2, selection.size());
    assertTrue(selection.contains(myProject.resolveFile("src/main/unix/files/opt/comp/myapp/etc/myapp.conf")));
    assertTrue(selection.contains(myProject.resolveFile("Included.java")));
}