Search in sources :

Example 56 with FileFilter

use of java.io.FileFilter in project ACS by ACS-Community.

the class ConfigFileFinder method run.

/**
	 * Gets all Files under {@link #baseDir} whose name ends with any of the Strings given in {@link #fileEndings},
	 * and runs them through the filter chain to suppress files of known and safe content.
	 * @return
	 */
private void run() {
    String msg = "Tool " + getClass().getSimpleName() + " will search for configuration files in '" + baseDir + "' and below, suspecting all files ending with ";
    for (Iterator<String> iter = fileEndings.iterator(); iter.hasNext(); ) {
        msg += "'" + iter.next() + "'";
        if (iter.hasNext()) {
            msg += ", ";
        }
    }
    msg += " and will then prune those files recognized by any of the filters ";
    for (Iterator<ConfigFileRedeemer> iter = redeemers.iterator(); iter.hasNext(); ) {
        msg += iter.next().getName();
        if (iter.hasNext()) {
            msg += ", ";
        }
    }
    msg += ". ";
    if (targetDir != null) {
        msg += "The remaining potential config files are copied to '" + targetDir + "' with their original directory structure ";
        if (targetFilesFlat) {
            msg += "flattened.";
        } else {
            msg += "maintained.";
        }
    }
    logger.info(msg);
    FileFilter fileFilter = new FileFilter() {

        public boolean accept(File pathname) {
            if (pathname.isDirectory()) {
                return true;
            }
            String name = pathname.getName();
            for (Iterator iter = fileEndings.iterator(); iter.hasNext(); ) {
                String fnEnding = (String) iter.next();
                if (name.endsWith(fnEnding)) {
                    return true;
                }
            }
            return false;
        }
    };
    runRecursive(baseDir, fileFilter);
}
Also used : Iterator(java.util.Iterator) FileFilter(java.io.FileFilter) File(java.io.File)

Example 57 with FileFilter

use of java.io.FileFilter in project cubrid-manager by CUBRID.

the class CubridJdbcManager method loadDefaultJdbcs.

/**
	 * Get JDBC driver from plugins installation directory
	 * 
	 * @return the JDBC driver
	 */
public void loadDefaultJdbcs() {
    List<File> fileList = getDefaultJDBCPath();
    for (File filePath : fileList) {
        if (filePath != null && filePath.exists() && filePath.isDirectory()) {
            File[] listFiles = filePath.listFiles(new FileFilter() {

                public boolean accept(File file) {
                    String fileName = file.getName().trim().toLowerCase();
                    return file.isFile() && (fileName.matches("^JDBC\\S*.jar") || fileName.matches("^jdbc\\S*.jar") || fileName.matches("^CUBRID_JDBC\\S*.jar") || fileName.matches("^cubrid_jdbc\\S*.jar"));
                }
            });
            for (File file : listFiles) {
                String path = file.getAbsolutePath();
                registerClassLoader(defaultVersion2FileMap, path);
            }
        }
    }
}
Also used : FileFilter(java.io.FileFilter) File(java.io.File)

Example 58 with FileFilter

use of java.io.FileFilter in project cradle by BingLau7.

the class ClassUtil method addClass.

private static void addClass(Set<Class<?>> classSet, String packagePath, String packageName) {
    File[] files = new File(packagePath).listFiles(new FileFilter() {

        public boolean accept(File file) {
            return (file.isFile() && file.getName().endsWith(".class")) || file.isDirectory();
        }
    });
    for (File file : files) {
        String fileName = file.getName();
        if (file.isFile()) {
            String className = fileName.substring(0, fileName.lastIndexOf("."));
            if (StringUtils.isNotEmpty(packageName)) {
                className = packagePath + "." + className;
            }
            doAddClass(classSet, className);
        } else {
            String subPackagePath = fileName;
            if (StringUtils.isNotEmpty(packagePath)) {
                subPackagePath = packagePath + "/" + subPackagePath;
            }
            String subPackageName = fileName;
            if (StringUtils.isNotEmpty(packageName)) {
                subPackageName = packageName + "." + subPackageName;
            }
            addClass(classSet, subPackagePath, subPackageName);
        }
    }
}
Also used : FileFilter(java.io.FileFilter) JarFile(java.util.jar.JarFile) File(java.io.File)

Example 59 with FileFilter

use of java.io.FileFilter in project kotlin by JetBrains.

the class AbstractLoadJavaTest method doTestJavaAgainstKotlin.

protected void doTestJavaAgainstKotlin(String expectedFileName) throws Exception {
    File expectedFile = new File(expectedFileName);
    File sourcesDir = new File(expectedFileName.replaceFirst("\\.txt$", ""));
    FileUtil.copyDir(sourcesDir, new File(tmpdir, "test"), new FileFilter() {

        @Override
        public boolean accept(@NotNull File pathname) {
            return pathname.getName().endsWith(".java");
        }
    });
    CompilerConfiguration configuration = KotlinTestUtils.newConfiguration(ConfigurationKind.JDK_ONLY, getJdkKind());
    ContentRootsKt.addKotlinSourceRoot(configuration, sourcesDir.getAbsolutePath());
    JvmContentRootsKt.addJavaSourceRoot(configuration, new File("compiler/testData/loadJava/include"));
    JvmContentRootsKt.addJavaSourceRoot(configuration, tmpdir);
    final KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
    AnalysisResult result = TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(environment.getProject(), environment.getSourceFiles(), new CliLightClassGenerationSupport.NoScopeRecordCliBindingTrace(), configuration, new Function1<GlobalSearchScope, PackagePartProvider>() {

        @Override
        public PackagePartProvider invoke(GlobalSearchScope scope) {
            return new JvmPackagePartProvider(environment, scope);
        }
    });
    PackageViewDescriptor packageView = result.getModuleDescriptor().getPackage(TEST_PACKAGE_FQNAME);
    checkJavaPackage(expectedFile, packageView, result.getBindingContext(), COMPARATOR_CONFIGURATION);
}
Also used : CliLightClassGenerationSupport(org.jetbrains.kotlin.cli.jvm.compiler.CliLightClassGenerationSupport) AnalysisResult(org.jetbrains.kotlin.analyzer.AnalysisResult) KotlinCoreEnvironment(org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) JvmPackagePartProvider(org.jetbrains.kotlin.cli.jvm.compiler.JvmPackagePartProvider) CompilerConfiguration(org.jetbrains.kotlin.config.CompilerConfiguration) JvmPackagePartProvider(org.jetbrains.kotlin.cli.jvm.compiler.JvmPackagePartProvider) FileFilter(java.io.FileFilter) KtFile(org.jetbrains.kotlin.psi.KtFile) File(java.io.File)

Example 60 with FileFilter

use of java.io.FileFilter in project bigbluebutton by bigbluebutton.

the class RecordingService method getDirectories.

private File[] getDirectories(String path) {
    File dir = new File(path);
    FileFilter fileFilter = new FileFilter() {

        public boolean accept(File file) {
            return file.isDirectory();
        }
    };
    return dir.listFiles(fileFilter);
}
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