List of usage examples for java.io FilenameFilter FilenameFilter
FilenameFilter
From source file:com.jdom.tvshowdownloader.integration.MockNzbDownloader.java
@Override public void downloadNzb(SeriesDownload download) { super.downloadNzb(download); String[] nzbs = SeriesConfiguration.NZB_QUEUE_DIRECTORY.list(new FilenameFilter() { @Override// w w w .j a va 2s. c o m public boolean accept(File dir, String name) { return name.endsWith(".nzb"); } }); if (nzbs != null) { for (String string : nzbs) { File file = new File(SeriesConfiguration.NZB_QUEUE_DIRECTORY, string); File destinationFolder = new File(SeriesConfiguration.NZB_DOWNLOADED_DIRECTORY, file.getName().replaceAll(".nzb", "")); try { org.apache.commons.io.FileUtils.moveFileToDirectory(file, destinationFolder, true); } catch (IOException e) { throw new RuntimeException(e); } } } }
From source file:com.adguard.compiler.FileUtil.java
private static void copyCommonFiles(File source, File dest, Browser browser) throws Exception { //copy filters and subscriptions File sourceFilters = new File(source, "filters"); File destFilters = new File(dest, "filters"); copyDirectory(sourceFilters, destFilters); //copy locales File sourceLocales = new File(source, "_locales"); File destLocales = new File(dest, "_locales"); copyDirectory(sourceLocales, destLocales); //copy html pages and css styles File sourcePages = new File(source, "pages"); File destPages = new File(dest, "pages"); copyDirectory(sourcePages, destPages); //customize html files File[] htmlFiles = destPages.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".html"); }/* w ww . j av a 2s .com*/ }); if (htmlFiles != null) { for (File htmlFile : htmlFiles) { processHtmlFile(htmlFile, browser); } } //copy lib folder File sourceLib = new File(source, "lib"); File destLib = new File(dest, "lib"); copyDirectory(sourceLib, destLib); }
From source file:com.cloudera.recordbreaker.schemadict.SchemaDictionary.java
/** * Load the schema dictionary from the given directory. */// w w w . ja v a 2 s.c o m public SchemaDictionary(File dir) throws IOException { this.dir = dir.getCanonicalFile(); if (!dir.exists()) { if (!dir.mkdirs()) { throw new IOException("Could not create: " + dir); } } File dictFiles[] = dir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(SchemaDictionaryEntry.SUMMARY_ENDING); } }); for (int i = 0; i < dictFiles.length; i++) { String name = dictFiles[i].getName(); String fileRoot = name.substring(0, name.length() - SchemaDictionaryEntry.SUMMARY_ENDING.length()); SchemaDictionaryEntry sde = new SchemaDictionaryEntry(); sde.loadDictionaryEntry(dir, fileRoot); dictElts.add(sde); } }
From source file:com.hydroLibCreator.action.Creator.java
private void setSortedAudioFileslist() { this.audioFileslist = sourceDir.list(); FilenameFilter filter = new FilenameFilter() { @Override/*from www .j a v a 2s. co m*/ public boolean accept(File dir, String name) { return false; } }; if (audioFileslist == null || audioFileslist.length == -1) throw new ApplicationException("Missing Audio Files Exception", "Please make sure your directory has audio files"); Arrays.sort(audioFileslist); }
From source file:net.orfjackal.dimdwarf.server.ApplicationLoader.java
private static File[] listJarsInDirectory(File dir) { return dir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".jar"); }/* w w w . jav a2s.co m*/ }); }
From source file:com.walmartlabs.mupd8.application.Config.java
public Config(File directory) throws IOException { File[] files = directory.listFiles(new FilenameFilter() { @Override//from ww w . j a va2 s.c o m public boolean accept(File dir, String name) { return name.endsWith(".cfg"); } }); if (files == null) { throw new FileNotFoundException("Configuration path " + directory.toString() + " is not a directory."); } Arrays.sort(files, new Comparator<File>() { @Override public int compare(File o1, File o2) { return o1.getName().compareTo(o2.getName()); } }); applyFiles(configuration, files); workerJSONs = extractWorkerJSONs(configuration); }
From source file:de.fatalix.bookery.bl.background.importer.CalibriImporter.java
@Override public void executeJob(Timer timer) { logger.debug("Starting batch job..."); DateTimeZone.setDefault(DateTimeZone.UTC); BatchJobConfiguration jobConfig = (BatchJobConfiguration) timer.getInfo(); Gson gson = new Gson(); CalibriImporterConfiguration config = gson.fromJson(jobConfig.getConfigurationXML(), CalibriImporterConfiguration.class); File importFolder = new File(config.getImportFolder()); if (importFolder.isDirectory()) { File[] zipFiles = importFolder.listFiles(new FilenameFilter() { @Override/*from w ww . ja v a 2 s .co m*/ public boolean accept(File dir, String name) { return name.endsWith(".zip"); } }); for (File zipFile : zipFiles) { try { processArchive(zipFile.toPath(), config.getBatchSize()); logger.info("Processed file " + zipFile.getName()); } catch (IOException ex) { logger.error("Cannot process " + zipFile.getName(), ex); } } } else { logger.error("Import folder: " + importFolder.getAbsolutePath() + " cannot be read!"); } }
From source file:com.consol.citrus.admin.util.FileHelperImpl.java
/** * {@inheritDoc}/*from w w w . ja v a2 s . c om*/ */ public String[] getFiles(File directory, final String fileExtension) { List<String> fileNames = new ArrayList<String>(); if (!directory.exists()) { return new String[] {}; } File[] found = directory.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(fileExtension); } }); for (File file : found) { fileNames.add(FilenameUtils.getBaseName(file.getName())); } return fileNames.toArray(new String[fileNames.size()]); }
From source file:eu.ggnet.dwoss.util.ImageFinder.java
public URL findImageUrl(final int id) { if (path == null || (!path.exists() && !path.isDirectory())) return errorUrl; String images[] = path.list(new FilenameFilter() { @Override/*from w w w. j a v a 2 s.c o m*/ public boolean accept(File dir, String name) { if (name.toLowerCase().endsWith("_" + id + ".jpg")) return true; if (name.toLowerCase().endsWith("_" + id + ".gif")) return true; if (name.toLowerCase().endsWith("_" + id + ".png")) return true; return false; } }); if (images == null || images.length == 0) return noimageUrl; try { return new File(path, images[0]).toURI().toURL(); } catch (MalformedURLException e) { throw new RuntimeException("Error in URL creation", e); } }
From source file:de.langmi.spring.batch.examples.playground.file.multiresourcepartitioner.FiltersFoldersMultiResourcePartitioner.java
public FiltersFoldersMultiResourcePartitioner(final String filePath, final List<String> acceptedFolders) throws Exception { LOG.debug("entering MRP"); final List<FileSystemResource> files = new ArrayList<FileSystemResource>(); runNestedDirs(new File(filePath), files, new FilenameFilter() { @Override/*from ww w.ja v a2 s .c o m*/ public boolean accept(File dir, String name) { // accept all files, made easy here, files shall contain a suffix separator if (name.contains(".")) { return true; } else if (acceptedFolders.contains(name)) { return true; } else { return false; } } }); this.setResources(files.toArray(new Resource[0])); }