org.apache.commons.io.filefilter.IOFileFilter Java Examples

The following examples show how to use org.apache.commons.io.filefilter.IOFileFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: aion-germany   Author: AionGermany   File: FileUtils.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Finds files within a given directory (and optionally its
 * subdirectories). All files found are filtered by an IOFileFilter.
 *
 * @param files the collection of files found.
 * @param directory the directory to search in.
 * @param filter the filter to apply to files and directories.
 * @param includeSubDirectories indicates if will include the subdirectories themselves
 */
private static void innerListFiles(Collection<File> files, File directory,
        IOFileFilter filter, boolean includeSubDirectories) {
    File[] found = directory.listFiles((FileFilter) filter);
    
    if (found != null) {
        for (File file : found) {
            if (file.isDirectory()) {
                if (includeSubDirectories) {
                    files.add(file);
                }
                innerListFiles(files, file, filter, includeSubDirectories);
            } else {
                files.add(file);
            }
        }
    }
}
 
Example #2
Source Project: o2oa   Author: o2oa   File: MetaModelBuilder.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
private static List<File> classpath(File o2oadir, File outputdir) {
	List<File> cp = new ArrayList<>();

	cp.add(outputdir);

	IOFileFilter filter = new WildcardFileFilter("x_base_core_project.jar");
	for (File o : FileUtils.listFiles(new File(o2oadir, "o2server/store/jars"), filter, null)) {
		cp.add(o);
	}

	ClassLoader cl = MetaModelBuilder.class.getClassLoader();

	URL[] urls = ((URLClassLoader) cl).getURLs();

	for (URL url : urls) {
		cp.add(new File(url.getFile()));
	}
	return cp;
}
 
Example #3
protected IOFileFilter getPathBasedFileFilter() {
    List<File> selectedFiles = getSelectedDirectories(getSelectedPaths());
    if (selectedFiles.isEmpty()) {
        return null;
    }
    IOFileFilter fileFilter = null;
    for (File selectedFile : selectedFiles) {
        IOFileFilter subFilter = new SubDirectoryFileFilter(selectedFile);
        if (fileFilter == null) {
            fileFilter = subFilter;
        }
        else {
            fileFilter = FileFilterUtils.orFileFilter(fileFilter, subFilter);
        }
    }
    return fileFilter;
}
 
Example #4
Source Project: varOne   Author: SparkMonitor   File: FsMetricsReaderTest.java    License: MIT License 6 votes vote down vote up
private void assertContent(IOFileFilter filter, Map<String, List<MetricTuple>> result) throws IOException{
	for(Entry<String, List<MetricTuple>> entry: result.entrySet()){
		File logFile =  new File(metricsDir+"//"+entry.getKey());
		assertTrue(filter.accept(logFile));
		int lineNum = 0;
		List<MetricTuple> tuples = entry.getValue();
		List<String> lines = FileUtils.readLines(logFile);
		lines.remove(0);
		for(MetricTuple tuple: tuples){
			String[] pair = lines.get(lineNum).split(",");
			assertEquals(pair[0], String.valueOf(tuple.getTime()));
			assertEquals(pair[1], tuple.getValue());
			lineNum++;
		}
	}
}
 
Example #5
Source Project: japi   Author: dounine   File: ProjectImpl.java    License: MIT License 6 votes vote down vote up
@Override
public List<IPackage> getPackages() {
    String masterProjectActionPath = JapiClient.getConfig().getPrefixPath() + JapiClient.getConfig().getProjectJavaPath() + JapiClient.getConfig().getPostfixPath() + "/" + JapiClient.getConfig().getActionReletivePath();
    File actionFold = new File(masterProjectActionPath);
    if (!actionFold.exists()) {
        throw new JapiException(masterProjectActionPath + " fold not exists.");
    }
    final IOFileFilter dirFilter = FileFilterUtils.asFileFilter(new FileFilter() {
        @Override
        public boolean accept(File pathname) {
            return pathname.isDirectory();
        }
    });
    Collection<File> folds = FileUtils.listFilesAndDirs(actionFold, dirFilter, TrueFileFilter.INSTANCE);
    List<IPackage> packages = new ArrayList<>(folds.size());
    for (File fold : folds) {
        if (!fold.getAbsolutePath().equals(actionFold.getAbsolutePath())) {
            PackageImpl packageImpl = new PackageImpl();
            packageImpl.setPackageFold(fold);
            packages.add(packageImpl);
        }
    }
    return packages;
}
 
Example #6
Source Project: japi   Author: dounine   File: PackageImpl.java    License: MIT License 6 votes vote down vote up
@Override
public List<IAction> getActions() {
    final IOFileFilter dirFilter = FileFilterUtils.asFileFilter(new FileFilter() {
        @Override
        public boolean accept(File pathname) {
            return pathname.getName().endsWith(".java") && !pathname.getName().equals("package-info.java");
        }
    });
    Collection<File> actionFiles = FileUtils.listFiles(packageFold, dirFilter, null);
    List<IAction> actions = new ArrayList<>();
    for (File actionFile : actionFiles) {
        ActionImpl action = new ActionImpl();
        action.setActionFile(actionFile);
        actions.add(action);
    }
    return actions;
}
 
Example #7
Source Project: OpenAs2App   Author: OpenAS2   File: TestUtils.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Wait till a file will occur on the file system.
 *
 * @param parent     a directory where file will be.
 * @param fileFilter a filter to scan the parent dir.
 * @param timeout    an amount of time units to wait
 * @param unit       a time unit
 * @return a file
 * @throws FileNotFoundException
 */
public static File waitForFile(File parent, IOFileFilter fileFilter, int timeout, TimeUnit unit) throws FileNotFoundException {
    long finishAt = System.currentTimeMillis() + unit.toMillis(timeout);
    waitForFile(parent, timeout, unit);
    while (finishAt - System.currentTimeMillis() > 0) {
        Collection<File> files = FileUtils.listFiles(parent, fileFilter, TrueFileFilter.INSTANCE);
        if (!files.isEmpty()) {
            if (files.size() > 1) {
                throw new IllegalStateException("Result is not unique.");
            } else {
                return files.iterator().next();
            }
        }
    }
    throw new FileNotFoundException(parent.getAbsolutePath() + ": " + fileFilter.toString());
}
 
Example #8
Source Project: api-mining   Author: mast-group   File: FilesetSplit.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param args
 */
public static void main(final String[] args) {
	if (args.length < 7) {
		System.err
				.println("Usage fromDirectory toDirectory fileSuffix <<segmentName_i> <weight_i> ...>");
		System.exit(-1);
	}

	final File fromDirectory = new File(args[0]);
	final File toDirectory = new File(args[1]);

	final IOFileFilter fileFilter = FileFilterUtils
			.suffixFileFilter(args[2]);

	final Map<String, Double> segments = Maps.newHashMap();

	for (int i = 3; i < args.length; i += 2) {
		segments.put(args[i], Double.valueOf(args[i + 1]));
	}

	LOGGER.info("Splitting files in segments " + segments);
	splitFiles(fromDirectory, toDirectory, segments, fileFilter,
			UNIFORM_FILE_WEIGHT);
}
 
Example #9
Source Project: celerio   Author: jaxio   File: IOUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Recurse in the folder to get the list all files and folders
 * <ul>
 * <li>do not recurse in svn folder</li>
 * <li>do not recurse in cvs folder</li>
 * <li>do not match .bak files</li>
 * <li>do not match .old files</li>
 * </ul>
 *
 * @param folder       the folder to parse
 * @param ioFileFilter additionnal IOFilter
 */
@SuppressWarnings("unchecked")
public Collection<String> listFiles(File folder, IOFileFilter ioFileFilter) {
    if (ioFileFilter == null) {
        ioFileFilter = FileFilterUtils.fileFileFilter();
    }
    OrFileFilter oldFilesFilter = new OrFileFilter();
    for (String exclude : DEFAULT_EXCLUDES_SUFFIXES) {
        oldFilesFilter.addFileFilter(FileFilterUtils.suffixFileFilter(exclude));
    }
    IOFileFilter notOldFilesFilter = FileFilterUtils.notFileFilter(oldFilesFilter);

    Collection<File> files = FileUtils.listFiles(folder, FileFilterUtils.andFileFilter(ioFileFilter, notOldFilesFilter),
            FileFilterUtils.makeSVNAware(FileFilterUtils.makeCVSAware(null)));
    Collection<String> ret = newArrayList();
    for (File file : files) {
        ret.add(file.getAbsolutePath());
    }
    return ret;
}
 
Example #10
Source Project: varOne   Author: SparkMonitor   File: ThreadPoolMetricsReaderTest.java    License: MIT License 6 votes vote down vote up
private void assertContent(IOFileFilter filter, Map<String, List<MetricTuple>> result) throws IOException{
	for(Entry<String, List<MetricTuple>> entry: result.entrySet()){
		File logFile =  new File(metricsDir+"//"+entry.getKey());
		assertTrue(filter.accept(logFile));
		int lineNum = 0;
		List<MetricTuple> tuples = entry.getValue();
		List<String> lines = FileUtils.readLines(logFile);
		lines.remove(0);
		for(MetricTuple tuple: tuples){
			String[] pair = lines.get(lineNum).split(",");
			assertEquals(pair[0], String.valueOf(tuple.getTime()));
			assertEquals(pair[1], tuple.getValue());
			lineNum++;
		}
	}
}
 
Example #11
Source Project: varOne   Author: SparkMonitor   File: JvmMetricsReaderTest.java    License: MIT License 6 votes vote down vote up
private void assertContent(IOFileFilter filter, Map<String, List<MetricTuple>> result) throws IOException{
	for(Entry<String, List<MetricTuple>> entry: result.entrySet()){
		File logFile =  new File(metricsDir+"//"+entry.getKey());
		assertTrue(filter.accept(logFile));
		int lineNum = 0;
		List<MetricTuple> tuples = entry.getValue();
		List<String> lines = FileUtils.readLines(logFile);
		lines.remove(0);
		for(MetricTuple tuple: tuples){
			String[] pair = lines.get(lineNum).split(",");
			assertEquals(pair[0], String.valueOf(tuple.getTime()));
			assertEquals(pair[1], tuple.getValue());
			lineNum++;
		}
	}
}
 
Example #12
Source Project: kfs   Author: kuali   File: LicenseHeaderUpdate.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
public static void handleJavaStyleComments( String baseDir ) throws Exception {
    IOFileFilter sourceFileFilter = FileFilterUtils.orFileFilter(
            FileFilterUtils.suffixFileFilter("java"),
            FileFilterUtils.suffixFileFilter("js") );
    sourceFileFilter = FileFilterUtils.orFileFilter(
            sourceFileFilter,
            FileFilterUtils.suffixFileFilter("css") );
    sourceFileFilter = FileFilterUtils.orFileFilter(
            sourceFileFilter,
            FileFilterUtils.suffixFileFilter("groovy") );
    sourceFileFilter = FileFilterUtils.makeSVNAware(sourceFileFilter);
    sourceFileFilter = FileFilterUtils.makeFileOnly(sourceFileFilter);

    LicensableFileDirectoryWalker dw = new LicensableFileDirectoryWalker(sourceFileFilter, "/*", " * ", " */");
    Collection<String> results = dw.run( baseDir );
    System.out.println( results );
}
 
Example #13
Source Project: kfs   Author: kuali   File: LicenseHeaderUpdate.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
public static void handleXMLStyleComments( String baseDir ) throws Exception {
    IOFileFilter sourceFileFilter = FileFilterUtils.orFileFilter(
            FileFilterUtils.suffixFileFilter("xml"),
            FileFilterUtils.suffixFileFilter("jrxml") );
    sourceFileFilter = FileFilterUtils.orFileFilter(
            sourceFileFilter,
            FileFilterUtils.suffixFileFilter("html") );
    sourceFileFilter = FileFilterUtils.orFileFilter(
            sourceFileFilter,
            FileFilterUtils.suffixFileFilter("htm") );
    sourceFileFilter = FileFilterUtils.orFileFilter(
            sourceFileFilter,
            FileFilterUtils.suffixFileFilter("xsd") );
    sourceFileFilter = FileFilterUtils.orFileFilter(
            sourceFileFilter,
            FileFilterUtils.suffixFileFilter("tld") );
    sourceFileFilter = FileFilterUtils.makeSVNAware(sourceFileFilter);
    sourceFileFilter = FileFilterUtils.makeFileOnly(sourceFileFilter);

    LicensableFileDirectoryWalker dw = new LicensableFileDirectoryWalker(sourceFileFilter, "<!--", "   - ", " -->");
    Collection<String> results = dw.run( baseDir );
    System.out.println( results );
}
 
Example #14
Source Project: kfs   Author: kuali   File: LicenseHeaderUpdate.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public static void handleJSPStyleComments( String baseDir ) throws Exception {
    IOFileFilter sourceFileFilter = FileFilterUtils.orFileFilter(
            FileFilterUtils.suffixFileFilter("jsp"),
            FileFilterUtils.suffixFileFilter("tag") );
    sourceFileFilter = FileFilterUtils.orFileFilter(
            sourceFileFilter,
            FileFilterUtils.suffixFileFilter("inc") );
    sourceFileFilter = FileFilterUtils.makeSVNAware(sourceFileFilter);
    sourceFileFilter = FileFilterUtils.makeFileOnly(sourceFileFilter);

    LicensableFileDirectoryWalker dw = new LicensableFileDirectoryWalker(sourceFileFilter, "<%--", "   - ", "--%>");
    Collection<String> results = dw.run( baseDir );
    System.out.println( results );
}
 
Example #15
Source Project: magarena   Author: magarena   File: ImportWorker.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a filter that returns everything in the "mods" folder except
 * the specified cubes which are distributed with each new release and
 * any existing themes which are now found in the "themes" folder.
 */
private FileFilter getModsFileFilter() {
    final String[] excludedCubes = new String[]{
        "legacy_cube.txt", "modern_cube.txt", "standard_cube.txt", "extended_cube.txt", "ubeefx_cube.txt"
    };
    final IOFileFilter cubesFilter = new NameFileFilter(excludedCubes, IOCase.INSENSITIVE);
    final IOFileFilter excludeCubes = FileFilterUtils.notFileFilter(cubesFilter);
    final IOFileFilter excludeThemes = FileFilterUtils.notFileFilter(new WildcardFileFilter("*_theme*"));
    return FileFilterUtils.and(excludeCubes, excludeThemes);
}
 
Example #16
Source Project: atlas   Author: alibaba   File: NativeSoUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param localNativeLibrariesDirectory
 * @param destinationDirectory
 * @param supportAbis                   Type of architecture supported
 * @param removeSoFiles
 */
public static void copyLocalNativeLibraries(final File localNativeLibrariesDirectory,
                                            final File destinationDirectory, Set<String> supportAbis,
                                            Set<String> removeSoFiles) {
    sLogger.info("Copying existing native libraries from " + localNativeLibrariesDirectory + " to "
                     + destinationDirectory);
    try {
        IOFileFilter filter = new NativeSoFilter(supportAbis, removeSoFiles);
        // First, determine whether there is a file of the same name, if there is a discrepancy
        Collection<File> files = FileUtils.listFiles(localNativeLibrariesDirectory, filter, TrueFileFilter.TRUE);
        List<String> dumpFiles = new ArrayList<String>();
        for (File file : files) {
            String relativePath = getRelativePath(localNativeLibrariesDirectory, file);
            File destFile = new File(destinationDirectory, relativePath);
            if (destFile.exists()) {
                String orgFileMd5 = MD5Util.getFileMD5(file);
                String destFileMd5 = MD5Util.getFileMD5(destFile);
                if (!orgFileMd5.equals(destFileMd5)) {
                    dumpFiles.add(file.getAbsolutePath() + " to " + destFile.getAbsolutePath());
                }
            }
        }
        if (dumpFiles.size() > 0) {
            throw new RuntimeException("Copy native so error,duplicate file exist!:\n"
                                           + StringUtils.join(dumpFiles, "\n"));
        }
        FileUtils.copyDirectory(localNativeLibrariesDirectory, destinationDirectory, filter);
    } catch (IOException e) {
        throw new RuntimeException("Could not copy native dependency.", e);
    }
}
 
Example #17
Source Project: neembuu-uploader   Author: Neembuu-Uploader   File: NUZipFileGenerator.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get all uploaders.
 * @return Returns all the uploader classes.
 */
private Collection<File> getAllUploaders(){
    return FileUtils.listFiles(new File(uploadersDirectory), new IOFileFilter() {

        @Override
        public boolean accept(File file) {
            return FilenameUtils.isExtension(file.getName(), "class");
        }

        @Override
        public boolean accept(File dir, String name) {
            return dir.getName().equals("uploaders");
        }
    }, null);
}
 
Example #18
Source Project: deadcode4j   Author: Scout24   File: WarPackagingHandler.java    License: Apache License 2.0 5 votes vote down vote up
private Repository getWebInfDirectory(@Nonnull MavenProject project) throws MojoExecutionException {
    final File webAppDirectory = calculateWebAppDirectory(project, false);
    final File directory = new File(webAppDirectory, "WEB-INF");
    IOFileFilter fileFilter = notFileFilter(or(
                    asFileFilter(new SubDirectoryFilter(directory, "lib")),
                    asFileFilter(new SubDirectoryFilter(directory, "classes")))
    );
    return new Repository(directory, fileFilter);

}
 
Example #19
Source Project: util4j   Author: juebanlin   File: DefaultClassSource.java    License: Apache License 2.0 5 votes vote down vote up
protected IOFileFilter buildFilterBySuffixs(String directory,String ...suffixs)
{
    IOFileFilter iOFileFilter=FileFilterUtils.directoryFileFilter(); //子目录变化
	for(String suffix:suffixs)
	{//后缀过滤器
		iOFileFilter=FileFilterUtils.or(iOFileFilter,FileFilterUtils.suffixFileFilter(suffix));
	}
    return iOFileFilter;
}
 
Example #20
Source Project: util4j   Author: juebanlin   File: DefaultClassSource.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 监视目录
 * @param directory
 * @param filter
 * @throws Exception 
 */
protected void monitorDir(String directory,IOFileFilter filter) throws Exception
{
	FileAlterationObserver observer=new FileAlterationObserver(directory,filter);
	observer.initialize();
	observer.addListener(fileListener);
	observers.add(observer);
}
 
Example #21
Source Project: kfs   Author: kuali   File: LicenseHeaderUpdate.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public static void handleSQLStyleComments( String baseDir ) throws Exception {
    IOFileFilter sourceFileFilter = FileFilterUtils.suffixFileFilter("sql");
    sourceFileFilter = FileFilterUtils.makeSVNAware(sourceFileFilter);
    sourceFileFilter = FileFilterUtils.makeFileOnly(sourceFileFilter);

    LicensableFileDirectoryWalker dw = new LicensableFileDirectoryWalker(sourceFileFilter, "--", "-- ", LINE_SEPARATOR);
    Collection<String> results = dw.run( baseDir );
    System.out.println( results );
}
 
Example #22
Source Project: varOne   Author: SparkMonitor   File: FsMetricsReaderTest.java    License: MIT License 5 votes vote down vote up
/**
 * Test method for {@link com.varone.node.reader.FsMetricsReader#read(java.lang.String, java.lang.String)}.
 * @throws IOException 
 */
public void testReadWith_EXEC_FS_HDFS_READ_BYTES() throws IOException {
	MetricsReader reader = new FsMetricsReader(null, MetricsType.EXEC_FS_HDFS_READ_BYTES);
	
	String applicationId = "application_1439169262151_0237";
	
	Map<String, List<MetricTuple>> result = reader.read(applicationId, metricsDir);
	IOFileFilter filter = new RegexFileFilter(applicationId+"(.\\d+)."+MetricsType.EXEC_FS_HDFS_READ_BYTES.type()+".csv");
	
	assertEquals(result.size(), 2);  
	this.assertContent(filter, result);
}
 
Example #23
Source Project: varOne   Author: SparkMonitor   File: FsMetricsReaderTest.java    License: MIT License 5 votes vote down vote up
/**
 * Test method for {@link com.varone.node.reader.FsMetricsReader#read(java.lang.String, java.lang.String)}.
 * @throws IOException 
 */
public void testReadWith_EXEC_FS_LOCAL_WRITE_BYTES() throws IOException {
	MetricsReader reader = new FsMetricsReader(null, MetricsType.EXEC_FS_LOCAL_WRITE_BYTES);
	
	String applicationId = "application_1439169262151_0237";
	
	Map<String, List<MetricTuple>> result = reader.read(applicationId, metricsDir);
	IOFileFilter filter = new RegexFileFilter(applicationId+"(.\\d+)."+MetricsType.EXEC_FS_LOCAL_WRITE_BYTES.type()+".csv");
	
	assertEquals(result.size(), 2);  
	this.assertContent(filter, result);
}
 
Example #24
Source Project: varOne   Author: SparkMonitor   File: FsMetricsReaderTest.java    License: MIT License 5 votes vote down vote up
/**
 * Test method for {@link com.varone.node.reader.FsMetricsReader#read(java.lang.String, java.lang.String)}.
 * @throws IOException 
 */
public void testReadWith_EXEC_FS_HDFS_LARGEREAD_OPS() throws IOException {
	MetricsReader reader = new FsMetricsReader(null, MetricsType.EXEC_FS_HDFS_LARGEREAD_OPS);
	
	String applicationId = "application_1439169262151_0237";
	
	Map<String, List<MetricTuple>> result = reader.read(applicationId, metricsDir);
	IOFileFilter filter = new RegexFileFilter(applicationId+"(.\\d+)."+MetricsType.EXEC_FS_HDFS_LARGEREAD_OPS.type()+".csv");
	
	assertEquals(result.size(), 2);  
	this.assertContent(filter, result);
}
 
Example #25
Source Project: collect-earth   Author: openforis   File: EarthProjectsService.java    License: MIT License 5 votes vote down vote up
private Collection<File> getSaikuFiles(File projectFolder) {
	return FileUtils.listFiles(projectFolder, new IOFileFilter() {
		
		@Override
		public boolean accept(File dir, String name) {
			return name.endsWith("saiku");
		}
		
		@Override
		public boolean accept(File file) {
			
			return file.getName().endsWith("saiku");
		}
	}, null);
}
 
Example #26
Source Project: MtgDesktopCompanion   Author: nicho92   File: FileTools.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void extractConfig(File fzip) throws IOException 
{
	IOFileFilter fileFilter1 =   FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter("logs", null));
	IOFileFilter fileFilter2 =   FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter("data", null));
	IOFileFilter exceptFilter =   FileFilterUtils.and(fileFilter1, fileFilter2 );
	
	
	try (ZipOutputStream out = new ZipOutputStream(new FileOutputStream(fzip))) {
		for(File f : FileUtils.listFilesAndDirs(MTGConstants.CONF_DIR, FileFileFilter.FILE, exceptFilter))
			addFile(f,out);
	}

}
 
Example #27
Source Project: pcgen   Author: PCGen   File: PrintPreviewDialog.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected Object[] doInBackground()
{
	IOFileFilter pdfFilter = FileFilterUtils.asFileFilter(this);
	IOFileFilter suffixFilter = FileFilterUtils.notFileFilter(new SuffixFileFilter(".fo"));
	IOFileFilter sheetFilter = FileFilterUtils.prefixFileFilter(Constants.CHARACTER_TEMPLATE_PREFIX);
	IOFileFilter fileFilter = FileFilterUtils.and(pdfFilter, suffixFilter, sheetFilter);

	IOFileFilter dirFilter = TrueFileFilter.INSTANCE;
	File dir = new File(ConfigurationSettings.getOutputSheetsDir());
	Collection<File> files = FileUtils.listFiles(dir, fileFilter, dirFilter);
	URI osPath = new File(ConfigurationSettings.getOutputSheetsDir()).toURI();
	return files.stream().map(v -> osPath.relativize(v.toURI())).toArray();
}
 
Example #28
Source Project: neembuu-uploader   Author: Neembuu-Uploader   File: NUZipFileGenerator.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get all accounts.
 * @return Returns all the account classes.
 */
private Collection<File> getAllAccounts(){
    return FileUtils.listFiles(new File(accountsDirectory), new IOFileFilter() {

        @Override
        public boolean accept(File file) {
            return FilenameUtils.isExtension(file.getName(), "class");
        }

        @Override
        public boolean accept(File dir, String name) {
            return dir.getName().equals("accounts");
        }
    }, null);
}
 
Example #29
Source Project: appassembler   Author: mojohaus   File: FileFilterHelper.java    License: MIT License 5 votes vote down vote up
/**
 * Make the given IOFileFilter aware of directories.
 *
 * @param filter The filter to make aware of directories.
 * @param directoryName The directory name which should be payed attention to.
 * @return The new generated filter.
 */
public static IOFileFilter makeDirectoryAware( IOFileFilter filter, String directoryName )
{

    IOFileFilter directoryAwareFilter =
        FileFilterUtils.notFileFilter( FileFilterUtils.andFileFilter( FileFilterUtils.directoryFileFilter(),
                                                                      FileFilterUtils.nameFileFilter( directoryName ) ) );

    return FileFilterUtils.andFileFilter( filter, directoryAwareFilter );
}
 
Example #30
Source Project: allure1   Author: allure-framework   File: AllureFileUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns list of files matches filters in specified directories
 *
 * @param directories which will using to find files
 * @param fileFilter  file filter
 * @param dirFilter   directory filter
 * @return list of files matches filters in specified directories
 */
public static List<File> listFiles(File[] directories, IOFileFilter fileFilter, IOFileFilter dirFilter) {
    List<File> files = new ArrayList<>();
    for (File directory : directories) {
        if (!directory.isDirectory()) {
            continue;
        }
        Collection<File> filesInDirectory = FileUtils.listFiles(directory,
                fileFilter,
                dirFilter);
        files.addAll(filesInDirectory);
    }
    return files;
}