List of usage examples for org.apache.commons.io.filefilter TrueFileFilter INSTANCE
IOFileFilter INSTANCE
To view the source code for org.apache.commons.io.filefilter TrueFileFilter INSTANCE.
Click Source Link
From source file:com.cyphercove.dayinspace.desktop.AtlasGenerator.java
public static void main(String[] args) throws Exception { //Delete old pack File oldPackFile = new File(TARGET_DIR + "/" + Assets.MAIN_ATLAS + Assets.ATLAS_EXTENSION); if (oldPackFile.exists()) { System.out.println("Deleting old pack file"); oldPackFile.delete();/* www .j a v a 2s . co m*/ } //Delete old font files Collection<File> oldFontFiles = FileUtils.listFiles(new File(TARGET_DIR), new RegexFileFilter(".*\\.fnt"), TrueFileFilter.INSTANCE); for (File file : oldFontFiles) { System.out.println("Copying font file: " + file.getName()); FileUtils.deleteQuietly(file); } //Create PNGs for GIF frames GifProcessor gifProcessor = new GifProcessor(0.015f); ArrayList<FileProcessor.Entry> gifFrames = gifProcessor.process(SOURCE_DIR, SOURCE_DIR); //Pack them TexturePacker.Settings settings = new TexturePacker.Settings(); settings.atlasExtension = Assets.ATLAS_EXTENSION; TexturePacker.process(settings, SOURCE_DIR, TARGET_DIR, Assets.MAIN_ATLAS); //Copy over any fonts Collection<File> fontFiles = FileUtils.listFiles(new File(SOURCE_DIR), new RegexFileFilter(".*\\.fnt"), TrueFileFilter.INSTANCE); File destDir = new File(TARGET_DIR); for (File file : fontFiles) { System.out.println("Copying font file: " + file.getName()); FileUtils.copyFileToDirectory(file, destDir); } //Delete the GIF frames that were generated. for (File file : gifProcessor.getGeneratedFiles()) file.delete(); }
From source file:gov.nasa.jpl.memex.pooledtimeseries.PoT.java
public static void main(String[] args) { System.loadLibrary(Core.NATIVE_LIBRARY_NAME); Option fileOpt = OptionBuilder.withArgName("file").hasArg().withLongOpt("file") .withDescription("Path to a single file").create('f'); Option dirOpt = OptionBuilder.withArgName("directory").hasArg().withLongOpt("dir") .withDescription("A directory with image files in it").create('d'); Option helpOpt = OptionBuilder.withLongOpt("help").withDescription("Print this message.").create('h'); Option pathFileOpt = OptionBuilder.withArgName("path file").hasArg().withLongOpt("pathfile") .withDescription(/*from w w w . j a v a2s . c o m*/ "A file containing full absolute paths to videos. Previous default was memex-index_temp.txt") .create('p'); Option outputFileOpt = OptionBuilder.withArgName("output file").withLongOpt("outputfile").hasArg() .withDescription("File containing similarity results. Defaults to ./similarity.txt").create('o'); Option jsonOutputFlag = OptionBuilder.withArgName("json output").withLongOpt("json") .withDescription("Set similarity output format to JSON. Defaults to .txt").create('j'); Option similarityFromFeatureVectorsOpt = OptionBuilder .withArgName("similarity from FeatureVectors directory") .withLongOpt("similarityFromFeatureVectorsDirectory").hasArg() .withDescription("calculate similarity matrix from given directory of feature vectors").create('s'); Options options = new Options(); options.addOption(dirOpt); options.addOption(pathFileOpt); options.addOption(fileOpt); options.addOption(helpOpt); options.addOption(outputFileOpt); options.addOption(jsonOutputFlag); options.addOption(similarityFromFeatureVectorsOpt); // create the parser CommandLineParser parser = new GnuParser(); try { // parse the command line arguments CommandLine line = parser.parse(options, args); String directoryPath = null; String pathFile = null; String singleFilePath = null; String similarityFromFeatureVectorsDirectory = null; ArrayList<Path> videoFiles = null; if (line.hasOption("dir")) { directoryPath = line.getOptionValue("dir"); } if (line.hasOption("pathfile")) { pathFile = line.getOptionValue("pathfile"); } if (line.hasOption("file")) { singleFilePath = line.getOptionValue("file"); } if (line.hasOption("outputfile")) { outputFile = line.getOptionValue("outputfile"); } if (line.hasOption("json")) { outputFormat = OUTPUT_FORMATS.JSON; } if (line.hasOption("similarityFromFeatureVectorsDirectory")) { similarityFromFeatureVectorsDirectory = line .getOptionValue("similarityFromFeatureVectorsDirectory"); } if (line.hasOption("help") || (line.getOptions() == null || (line.getOptions() != null && line.getOptions().length == 0)) || (directoryPath != null && pathFile != null && !directoryPath.equals("") && !pathFile.equals(""))) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("pooled_time_series", options); System.exit(1); } if (directoryPath != null) { File dir = new File(directoryPath); List<File> files = (List<File>) FileUtils.listFiles(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); videoFiles = new ArrayList<Path>(files.size()); for (File file : files) { String filePath = file.toString(); // When given a directory to load videos from we need to ensure that we // don't try to load the of.txt and hog.txt intermediate result files // that results from previous processing runs. if (!filePath.contains(".txt")) { videoFiles.add(file.toPath()); } } LOG.info("Added " + videoFiles.size() + " video files from " + directoryPath); } if (pathFile != null) { Path list_file = Paths.get(pathFile); videoFiles = loadFiles(list_file); LOG.info("Loaded " + videoFiles.size() + " video files from " + pathFile); } if (singleFilePath != null) { Path singleFile = Paths.get(singleFilePath); LOG.info("Loaded file: " + singleFile); videoFiles = new ArrayList<Path>(1); videoFiles.add(singleFile); } if (similarityFromFeatureVectorsDirectory != null) { File dir = new File(similarityFromFeatureVectorsDirectory); List<File> files = (List<File>) FileUtils.listFiles(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); videoFiles = new ArrayList<Path>(files.size()); for (File file : files) { String filePath = file.toString(); // We need to load only the *.of.txt and *.hog.txt values if (filePath.endsWith(".of.txt")) { videoFiles.add(file.toPath()); } if (filePath.endsWith(".hog.txt")) { videoFiles.add(file.toPath()); } } LOG.info("Added " + videoFiles.size() + " feature vectors from " + similarityFromFeatureVectorsDirectory); evaluateSimilarity(videoFiles, 1); } else { evaluateSimilarity(videoFiles, 1); } LOG.info("done."); } catch (ParseException exp) { // oops, something went wrong System.err.println("Parsing failed. Reason: " + exp.getMessage()); } }
From source file:com.bysailors.comparefolders.compareFiles.java
public static Set<File> getTreeList(File root) { Set<File> ret = new HashSet<File>( FileUtils.listFiles(root, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)); // for (File archivo : ret) // {// w ww. ja va 2 s .c o m // System.out.println(archivo.getAbsolutePath()); // } return ret; }
From source file:de.drippinger.serviceExtractor.files.FileSearch.java
/** * Find all ndf files.//from w ww . ja v a 2s . c om * * @param parameter the run parameter * @return a collection of ndf files */ public static Collection<File> findNdfFiles(@NonNull RunParameter parameter) { File rootFolder = new File(parameter.pathToFlows()); Collection<File> files = FileUtils.listFiles(rootFolder, FileFilterUtils.suffixFileFilter("ndf"), TrueFileFilter.INSTANCE); log.debug("Found {} NDF files", files.size()); return files; }
From source file:com.codercowboy.photo.organizer.service.PhotoIndexer.java
public static List<Photo> indexDirectory(String directoryAbsolutePath) throws Exception { File directory = new File(directoryAbsolutePath); if (!directory.exists()) { throw new IOException("Directory for indexing does not exist: " + directoryAbsolutePath); }//from ww w . j a va 2 s .c om if (!directory.canRead()) { throw new IOException( "Cannot read directory for indexing, permission denied: " + directoryAbsolutePath); } List<Photo> photos = new LinkedList<>(); for (File f : FileUtils.listFiles(directory, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { //TODO: this should be externally configurable if (".DS_Store".equals(f.getName())) { continue; } photos.add(indexFile(f)); } return photos; }
From source file:com.nuvolect.deepdive.util.OmniFileFilter.java
/** * Finds files within a given directory (and optionally its subdirectories) * which match an array of extensions.//from ww w .jav a 2 s . c o m * * @param directory the directory to search in * @param extensions an array of extensions, ex. {"java","xml"}. If this * parameter is {@code null}, all files are returned. * @param recursive if true all subdirectories are searched as well * @return an collection of java.io.File with the matching files */ public static Collection<OmniFile> listFiles(final OmniFile directory, final String[] extensions, final boolean recursive) { IOFileFilter filter; if (extensions == null) { filter = TrueFileFilter.INSTANCE; } else { final String[] suffixes = toSuffixes(extensions); filter = new SuffixFileFilter(suffixes); } return listFiles(directory, filter, recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE); }
From source file:hoot.services.utils.FileUtils.java
public static File getSubFolderFromFolder(String targetFolder, String subFolderName) { File ret = null;//from w w w. jav a 2 s . c om File folder = new File(targetFolder); List<File> files = (List<File>) org.apache.commons.io.FileUtils.listFilesAndDirs(folder, new NotFileFilter(TrueFileFilter.INSTANCE), DirectoryFileFilter.DIRECTORY); for (File file : files) { if (file.getName().equals(subFolderName)) { ret = file; break; } } return ret; }
From source file:com.sun.star.lib.loader.FileFind.java
/** * Looks for files recursively in a directory tree * @param inFolder/* w w w. jav a 2 s .c om*/ * @param findTheseFiles * @return */ public static URL[] findFiles(String inFolder, String[] findTheseFiles) { List<URL> urls = new ArrayList<URL>(0); Collection<File> files = FileUtils.listFiles(new File(inFolder), new NameFileFilter(findTheseFiles), TrueFileFilter.INSTANCE); for (File file : files) { try { urls.add(file.toURI().toURL()); } catch (MalformedURLException ex) { log.error("error while locating jar", ex); } } return urls.toArray(new URL[urls.size()]); }
From source file:com.denimgroup.threadfix.framework.impl.dotNetWebForm.AscxFileMappingsFileParser.java
public static Map<String, AscxFile> getMap(File rootDirectory) { if (!rootDirectory.exists() || !rootDirectory.isDirectory()) { throw new IllegalArgumentException( "Invalid directory passed to WebFormsEndpointGenerator: " + rootDirectory); }// ww w. ja v a 2 s .c o m Collection ascxFiles = FileUtils.listFiles(rootDirectory, new FileExtensionFileFilter("ascx"), TrueFileFilter.INSTANCE); Map<String, AscxFile> map = map(); for (Object aspxFile : ascxFiles) { if (aspxFile instanceof File) { File file = (File) aspxFile; String name = file.getName(); String key = name.contains(".") ? name.substring(0, name.indexOf('.')) : name; map.put(key, new AscxFile(file)); } } return map; }
From source file:net.rptools.tokentool.AppSetup.java
public static void install(String versionString) { System.setProperty("appHome", getAppHome("logs").getAbsolutePath()); log = LogManager.getLogger(AppSetup.class); File overlayVer = new File(getAppHome().getAbsolutePath() + "/version.txt"); Collection<File> existingOverLays = FileUtils.listFiles(AppConstants.OVERLAY_DIR, ImageUtil.SUPPORTED_FILE_FILTER, TrueFileFilter.INSTANCE); log.info("Overlays installed: " + existingOverLays.size()); // Only install overlays once or if version.text is missing or version is newer // Overlays are stored in a version packaged structure so we can later install only newer overlays if wanted String installedVersion = "0"; try {/*from w w w . j av a 2 s . c om*/ if (overlayVer.exists()) { installedVersion = FileUtils.readFileToString(overlayVer, Charset.defaultCharset()); } else { FileUtils.writeStringToFile(overlayVer, versionString, Charset.defaultCharset()); } } catch (IOException ioe) { log.error(ioe); } if (existingOverLays.isEmpty() || isNewerVersion(TokenTool.getVersion(), installedVersion)) { try { installDefaultOverlays(); } catch (IOException e) { log.error(e); } // Update version file to new version try { FileUtils.writeStringToFile(overlayVer, versionString, Charset.defaultCharset()); } catch (IOException e) { log.error(e); } } }