Search in sources :

Example 76 with FileFilter

use of java.io.FileFilter in project jackrabbit by apache.

the class LocalFileSystem method listFolders.

/**
     * {@inheritDoc}
     */
public String[] listFolders(String folderPath) throws FileSystemException {
    File file = new File(root, osPath(folderPath));
    File[] folders = file.listFiles(new FileFilter() {

        public boolean accept(File f) {
            return f.isDirectory();
        }
    });
    if (folders == null) {
        String msg = folderPath + " does not denote a folder";
        log.debug(msg);
        throw new FileSystemException(msg);
    }
    String[] entries = new String[folders.length];
    for (int i = 0; i < folders.length; i++) {
        entries[i] = folders[i].getName();
    }
    return entries;
}
Also used : FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) FileFilter(java.io.FileFilter) File(java.io.File)

Example 77 with FileFilter

use of java.io.FileFilter in project lucene-solr by apache.

the class DirectUpdateHandlerOptimizeTest method assertNumSegments.

private void assertNumSegments(String indexDir, int numSegs) {
    File file = new File(indexDir);
    File[] segs = file.listFiles(new FileFilter() {

        @Override
        public boolean accept(File file) {
            return file.getName().endsWith("cfs");
        }
    });
//
// TODO: we need a method that does not rely on physical inspection of the directory.
//
// assertTrue("Wrong number of segments: " + segs.length + " does not equal: " + numSegs, segs.length == numSegs);
}
Also used : FileFilter(java.io.FileFilter) File(java.io.File)

Example 78 with FileFilter

use of java.io.FileFilter in project poi by apache.

the class TestPPTX2PNG method data.

@Parameters(name = "{0}")
public static Collection<String> data() {
    final Set<String> data = new TreeSet<String>();
    for (String f : files.split(", ?")) {
        if (basedir == null) {
            data.add(f);
        } else {
            final Pattern p = Pattern.compile(f);
            basedir.listFiles(new FileFilter() {

                public boolean accept(File pathname) {
                    String name = pathname.getName();
                    if (p.matcher(name).matches()) {
                        data.add(name);
                    }
                    return false;
                }
            });
        }
    }
    return data;
}
Also used : Pattern(java.util.regex.Pattern) TreeSet(java.util.TreeSet) FileFilter(java.io.FileFilter) File(java.io.File) Parameters(org.junit.runners.Parameterized.Parameters)

Example 79 with FileFilter

use of java.io.FileFilter in project carbondata by apache.

the class SingleThreadFinalSortFilesMerger method startFinalMerge.

/**
   * This method will be used to merger the merged files
   *
   * @throws CarbonSortKeyAndGroupByException
   */
public void startFinalMerge() throws CarbonDataWriterException {
    // get all the merged files
    File file = new File(tempFileLocation);
    File[] fileList = file.listFiles(new FileFilter() {

        public boolean accept(File pathname) {
            return pathname.getName().startsWith(tableName);
        }
    });
    if (null == fileList || fileList.length == 0) {
        return;
    }
    startSorting(fileList);
}
Also used : FileFilter(java.io.FileFilter) File(java.io.File)

Example 80 with FileFilter

use of java.io.FileFilter in project carbondata by apache.

the class LocalCarbonFile method listFiles.

@Override
public CarbonFile[] listFiles(final CarbonFileFilter fileFilter) {
    if (!file.isDirectory()) {
        return null;
    }
    File[] files = file.listFiles(new FileFilter() {

        @Override
        public boolean accept(File pathname) {
            return fileFilter.accept(new LocalCarbonFile(pathname));
        }
    });
    if (files == null) {
        return new CarbonFile[0];
    }
    CarbonFile[] carbonFiles = new CarbonFile[files.length];
    for (int i = 0; i < carbonFiles.length; i++) {
        carbonFiles[i] = new LocalCarbonFile(files[i]);
    }
    return carbonFiles;
}
Also used : FileFilter(java.io.FileFilter) File(java.io.File)

Aggregations

FileFilter (java.io.FileFilter)281 File (java.io.File)267 ArrayList (java.util.ArrayList)59 IOException (java.io.IOException)53 JarFile (java.util.jar.JarFile)22 URL (java.net.URL)17 Test (org.junit.Test)16 HashMap (java.util.HashMap)15 FileNotFoundException (java.io.FileNotFoundException)11 FilenameFilter (java.io.FilenameFilter)11 HashSet (java.util.HashSet)11 FileInputStream (java.io.FileInputStream)10 Pattern (java.util.regex.Pattern)10 WildcardFileFilter (org.apache.commons.io.filefilter.WildcardFileFilter)10 MalformedURLException (java.net.MalformedURLException)9 URI (java.net.URI)9 Map (java.util.Map)7 Path (org.apache.hadoop.fs.Path)7 NotNull (org.jetbrains.annotations.NotNull)7 Treebank (edu.stanford.nlp.trees.Treebank)6