Search in sources :

Example 96 with FilenameFilter

use of java.io.FilenameFilter in project tdi-studio-se by Talend.

the class JavaJobExportReArchieveCreator method getLibJarFilenames.

private String[] getLibJarFilenames() {
    if (libFolder != null) {
        File[] files = libFolder.listFiles(new FilenameFilter() {

            @Override
            public boolean accept(File dir, String name) {
                return name.toLowerCase().endsWith(FileConstants.JAR_FILE_SUFFIX) || name.toLowerCase().endsWith(FileConstants.ZIP_FILE_SUFFIX) ? true : false;
            }
        });
        String[] filenames = new String[files.length];
        for (int i = 0; i < files.length; i++) {
            filenames[i] = files[i].getName();
        }
        return filenames;
    }
    return null;
}
Also used : FilenameFilter(java.io.FilenameFilter) ZipToFile(org.talend.repository.ui.utils.ZipToFile) File(java.io.File)

Example 97 with FilenameFilter

use of java.io.FilenameFilter in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class UserHistoryDictionaryTestsHelper method removeAllTestDictFiles.

/**
     * Remove all the test dictionary files created for the given locale.
     */
public static void removeAllTestDictFiles(final String filter, final Context context) {
    final FilenameFilter filenameFilter = new FilenameFilter() {

        @Override
        public boolean accept(final File dir, final String filename) {
            return filename.startsWith(UserHistoryDictionary.NAME + "." + filter);
        }
    };
    FileUtils.deleteFilteredFiles(context.getFilesDir(), filenameFilter);
}
Also used : FilenameFilter(java.io.FilenameFilter) File(java.io.File)

Example 98 with FilenameFilter

use of java.io.FilenameFilter in project jangaroo-tools by CoreMedia.

the class ExmlValidator method addXsdMappingsFromFilesInDirectory.

private boolean addXsdMappingsFromFilesInDirectory(Map<String, ExmlSchemaSource> schemas, File xsdsDirectory) {
    if (xsdsDirectory != null && xsdsDirectory.exists() && xsdsDirectory.isDirectory()) {
        File[] xsds = xsdsDirectory.listFiles(new FilenameFilter() {

            @Override
            public boolean accept(File dir, String name) {
                return name.endsWith(".xsd");
            }
        });
        for (final File xsd : xsds) {
            String namespace = Exmlc.EXML_CONFIG_URI_PREFIX + CompilerUtils.removeExtension(xsd.getName());
            // System.out.println("### adding EXML schema " + namespace + " from " + xsd.getPath());
            schemas.put(namespace, new ExmlSchemaFileSource(xsd));
        }
        return true;
    }
    return false;
}
Also used : FilenameFilter(java.io.FilenameFilter) ZipFile(java.util.zip.ZipFile) File(java.io.File)

Example 99 with FilenameFilter

use of java.io.FilenameFilter in project atmosphere by Atmosphere.

the class AtmosphereFramework method autoConfigureService.

protected void autoConfigureService(ServletContext sc) throws IOException {
    String path = handlersPath != DEFAULT_HANDLER_PATH ? handlersPath : realPath(sc, handlersPath);
    try {
        annotationProcessor = newClassInstance(AnnotationProcessor.class, (Class<AnnotationProcessor>) IOUtils.loadClass(getClass(), annotationProcessorClassName));
        logger.info("Atmosphere is using {} for processing annotation", annotationProcessorClassName);
        annotationProcessor.configure(config);
        if (!packages.isEmpty()) {
            for (String s : packages) {
                annotationProcessor.scan(s);
            }
        }
        // Second try.
        if (!annotationFound) {
            if (path != null) {
                annotationProcessor.scan(new File(path));
            }
            // Always scan library
            String pathLibs = libPath != DEFAULT_LIB_PATH ? libPath : realPath(sc, DEFAULT_LIB_PATH);
            if (pathLibs != null) {
                File libFolder = new File(pathLibs);
                File[] jars = libFolder.listFiles(new FilenameFilter() {

                    @Override
                    public boolean accept(File arg0, String arg1) {
                        return arg1.endsWith(".jar");
                    }
                });
                if (jars != null) {
                    for (File file : jars) {
                        annotationProcessor.scan(file);
                    }
                }
            }
        }
        if (!annotationFound && allowAllClassesScan) {
            logger.debug("Scanning all classes on the classpath");
            annotationProcessor.scanAll();
        }
    } catch (Throwable e) {
        logger.error("", e);
        return;
    } finally {
        if (annotationProcessor != null) {
            annotationProcessor.destroy();
        }
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) File(java.io.File)

Example 100 with FilenameFilter

use of java.io.FilenameFilter in project atmosphere by Atmosphere.

the class DefaultAnnotationProcessor method scanForAnnotation.

private void scanForAnnotation(AtmosphereFramework f) {
    List<String> packages = f.customAnnotationPackages();
    AnnotationDetector detector = new AnnotationDetector(atmosphereReporter);
    try {
        if (!packages.isEmpty()) {
            for (String p : packages) {
                logger.trace("Package {} scanned for @AtmosphereAnnotation", p);
                detector.detect(p);
            }
        }
        // Now look for application defined annotation
        String path = IOUtils.realPath(f.getServletContext(), f.getHandlersPath());
        if (path != null) {
            detector.detect(new File(path));
        }
        String pathLibs = IOUtils.realPath(f.getServletContext(), f.getLibPath());
        if (pathLibs != null) {
            File libFolder = new File(pathLibs);
            File[] jars = libFolder.listFiles(new FilenameFilter() {

                @Override
                public boolean accept(File arg0, String arg1) {
                    return arg1.endsWith(".jar");
                }
            });
            if (jars != null) {
                for (File file : jars) {
                    detector.detect(file);
                }
            }
        }
        // https://github.com/Atmosphere/atmosphere/issues/1292
        if (!coreAnnotationsFound.get()) {
            fallbackToManualAnnotatedClasses(getClass(), f, handler);
        }
    } catch (IOException e) {
        logger.warn("Unable to scan annotation", e);
    } finally {
        detector.destroy();
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) AnnotationDetector(org.atmosphere.util.annotation.AnnotationDetector) IOException(java.io.IOException) File(java.io.File)

Aggregations

FilenameFilter (java.io.FilenameFilter)354 File (java.io.File)350 IOException (java.io.IOException)87 ArrayList (java.util.ArrayList)61 Test (org.junit.Test)49 URL (java.net.URL)19 RandomAccessFile (java.io.RandomAccessFile)18 List (java.util.List)17 HashSet (java.util.HashSet)15 FileOutputStream (java.io.FileOutputStream)14 MalformedURLException (java.net.MalformedURLException)12 FileFilter (java.io.FileFilter)11 FileNotFoundException (java.io.FileNotFoundException)11 TestClient (org.syncany.tests.util.TestClient)11 FileWriter (java.io.FileWriter)10 HashMap (java.util.HashMap)10 ZipFile (java.util.zip.ZipFile)10 BufferedWriter (java.io.BufferedWriter)9 FileInputStream (java.io.FileInputStream)9 FileReader (java.io.FileReader)9