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);
}
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();
}
}
}
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();
}
}
use of java.io.FilenameFilter in project AndroidChromium by JackyAndroid.
the class CrashFileManager method getMatchingFiles.
@VisibleForTesting
File[] getMatchingFiles(final Pattern pattern) {
// Get dump dir and get all files with specified suffix. The path
// constructed here must match chrome_paths.cc (see case
// chrome::DIR_CRASH_DUMPS).
File crashDir = getCrashDirectoryIfExists();
if (crashDir == null) {
return new File[] {};
}
File[] minidumps = crashDir.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String filename) {
Matcher match = pattern.matcher(filename);
int tries = readAttemptNumber(filename);
return match.find() && tries < MinidumpUploadService.MAX_TRIES_ALLOWED;
}
});
return minidumps;
}
use of java.io.FilenameFilter in project zaproxy by zaproxy.
the class LocaleUtils method readAvailableLocales.
private static List<String> readAvailableLocales() {
File dir = new File(Constant.getZapInstall(), Constant.LANG_DIR);
FilenameFilter filter = new MessagesPropertiesFilenameFilter();
String[] files = dir.list(filter);
if (files == null || files.length == 0) {
logger.error("Failed to find any locale files in directory " + dir.getAbsolutePath());
return new ArrayList<>(0);
}
List<String> locales = new ArrayList<>(files.length);
final int baseFilenameLength = MESSAGES_BASE_FILENAME.length();
for (String file : Arrays.asList(files)) {
if (file.startsWith(MESSAGES_BASE_FILENAME)) {
locales.add(file.substring(baseFilenameLength, file.indexOf(".")));
}
}
return locales;
}
Aggregations