List of usage examples for org.apache.commons.io.filefilter RegexFileFilter RegexFileFilter
public RegexFileFilter(Pattern pattern)
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();// w w w . j a va 2s .c om } //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:com.blogspot.devsk.l2j.geoconv.GeoGonv.java
public static void main(String[] args) { if (args == null || args.length == 0) { System.out.println("File name was not specified, [\\d]{1,2}_[\\d]{1,2}.txt will be used"); args = new String[] { "[\\d]{1,2}_[\\d]{1,2}.txt" }; }// w w w.j av a 2s .c o m File dir = new File("."); File[] files = dir.listFiles((FileFilter) new RegexFileFilter(args[0])); ArrayList<File> checked = new ArrayList<File>(); for (File file : files) { if (file.isDirectory() || file.isHidden() || !file.exists()) { System.out.println(file.getAbsoluteFile() + " was ignored."); } else { checked.add(file); } } if (OUT_DIR.exists() && OUT_DIR.isDirectory() && OUT_DIR.listFiles().length > 0) { try { System.out.println("Directory with generated files allready exists, making backup..."); FileUtils.moveDirectory(OUT_DIR, new File("generated-backup-" + System.currentTimeMillis())); } catch (IOException e) { e.printStackTrace(); } } if (!OUT_DIR.exists()) { OUT_DIR.mkdir(); } for (File file : checked) { GeoConvThreadFactory.startThread(new ParseTask(file)); } }
From source file:com.nuance.expertassistant.ContentCrawler.java
public static void main(String args[]) { if (args.length == 0) { ContentExtractor.startDocument("Test3", "/Users/abhishek_rohatgi/" + "Test3" + ".xml"); ContentExtractor.extract("http://www.audihelp.com/auda-147-tyre_repairs.html"); ContentExtractor.endDocument();/*from ww w .j a v a 2s . c o m*/ } else { final ContentCrawlerOptions options = new ContentCrawlerOptions(args); final ContentCrawlerInputTypes inputType = ContentCrawlerOptions.getInputType(); if (ContentCrawlerInputTypes.FILE.equals(inputType)) { final File outputFile = new File(getOutput()); if (!outputFile.getParentFile().exists()) { outputFile.getParentFile().mkdirs(); } translateFile(getInput(), getOutput()); } else if (ContentCrawlerInputTypes.FOLDER.equals(inputType)) { final File outputFolder = new File(getOutput()); final Collection<File> inputFiles = FileUtils.listFiles(new File(getInput()), new RegexFileFilter("^(.*\\.(html)?)"), DirectoryFileFilter.DIRECTORY); for (final File inputFile : inputFiles) { final String outputFileName = inputFile.getAbsolutePath().substring(getInput().length()) + ".xml"; final File outputFile = new File(outputFolder, outputFileName); if (!outputFile.getParentFile().exists()) { outputFile.getParentFile().mkdirs(); } translateFile(inputFile.getAbsolutePath(), outputFile.getAbsolutePath()); } } else { ContentExtractor.startDocument(getInput(), getOutput()); ContentExtractor.extract(getInput()); ContentExtractor.endDocument(); } } }
From source file:com.makkajai.ObjCToCpp.java
/** * Main Method//w ww . j a va 2 s . com * * @param args - First argument is the input directory to scan and second is the output directory to write files to. * @throws IOException */ public static void main(String[] args) throws IOException { if (args.length < 2) { System.out.println("Invalid Arguments!"); System.out.println( "Usage: java com.makkajai.ObjCToCpp \"<directory to scan for .h and .m files>\" \"<directory to write .h and .cpp files>\""); return; } String inputDirectory = args[0]; String outputDirectory = args[1]; // String inputDirectory = "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/scenes"; // String outputDirectory = "/Users/administrator/playground/projarea/monster-math-cross-platform/monster-math-2/Classes/Makkajai/scenes"; List<String> exceptFiles = new ArrayList<String>(); if (args.length == 3) { BufferedReader bufferedInputStream = new BufferedReader(new FileReader(args[2])); String exceptFile = null; while ((exceptFile = bufferedInputStream.readLine()) != null) { if (exceptFile.equals("")) continue; exceptFiles.add(exceptFile); } } //Getting all the files from the input directory. final List<File> files = new ArrayList<File>(FileUtils.listFiles(new File(inputDirectory), new RegexFileFilter(FILE_NAME_WITH_H_OR_M), DirectoryFileFilter.DIRECTORY)); // String fileName = //// "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/Utils/MakkajaiEnum" //// "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/Utils/MakkajaiUtil" //// "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/Home" //// "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/Activities/gnumchmenu/PlayStrategy" //// "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/Characters/Character" // "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/Activities/gnumchmenu/GnumchScene" //// "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/ParentScene" //// "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/BaseSkillView" //// "/Users/administrator/playground/projarea/math-monsters-2/makkajai-number-muncher/makkajai-ios/Makkajai/Makkajai/YDLayerBase" // ; //The instance of the translator. ObjCToCppTranslator visitor = new ObjCToCppTranslator(); for (int i = 0; i < files.size();) { File currentFile = files.get(i); String filePathRelativeToInput = currentFile.getAbsolutePath().replace(inputDirectory, ""); Date startTime = new Date(); try { final TranslateFileInput translateFileInput = new TranslateFileInput(inputDirectory, outputDirectory, filePathRelativeToInput, false); if (nextFileIsM(currentFile, files, i)) { try { if (isIgnoredFile(filePathRelativeToInput, exceptFiles)) continue; translateFileInput.dryRun = true; visitor.translateFile(translateFileInput); Date stopTime = new Date(); System.out.println("Dry run File: " + translateFileInput.filePathRelativeToInput + " Time Taken: " + getDelta(startTime, stopTime)); Date startTime1 = new Date(); translateFileInput.filePathRelativeToInput = filePathRelativeToInput.replace(H, M); translateFileInput.dryRun = false; visitor.translateFile(translateFileInput); stopTime = new Date(); System.out.println("Processed File: " + translateFileInput.filePathRelativeToInput + " Time Taken: " + getDelta(startTime1, stopTime)); Date startTime2 = new Date(); translateFileInput.filePathRelativeToInput = filePathRelativeToInput; translateFileInput.dryRun = false; visitor.translateFile(translateFileInput); stopTime = new Date(); System.out.println("Processed File: " + translateFileInput.filePathRelativeToInput + " Time Taken: " + getDelta(startTime2, stopTime)); } catch (Exception e) { e.printStackTrace(); System.out.println("###########################Error Processing: " + filePathRelativeToInput + ", Continuing with next set of tiles"); } finally { i += 2; } continue; } if (!isIgnoredFile(filePathRelativeToInput, exceptFiles)) visitor.translateFile(translateFileInput); i++; } catch (Exception e) { e.printStackTrace(); System.out.println("###########################Error Processing: " + filePathRelativeToInput + ", Continuing with next set of tiles"); } finally { Date stopTime = new Date(); // System.out.println("Processed File(s): " + filePathRelativeToInput.replaceAll(H_OR_M, "") + " Time Taken: " + getDelta(startTime, stopTime)); } } }
From source file:com.ontotext.s4.SBTDemo.Main.java
public static void main(String[] args) { /*//w ww . ja va2 s . c o m * Read log4j properties file. */ org.apache.log4j.PropertyConfigurator.configure(args.length >= 1 ? args[1] : DEFAULT_LOG4J_FILE); /* * Read properties file List all annotated files. We should * use absolute path to the files */ init(args); ProcessingDocuments processingDocuments = new ProcessingDocuments( programProperties.getProperty(PropertiesNames.S4_API_KEY), programProperties.getProperty(PropertiesNames.S4_API_PASS), programProperties.getProperty(PropertiesNames.RAW_FOLDER), programProperties.getProperty(PropertiesNames.ANNOTATED_FOLDER), programProperties.getProperty(PropertiesNames.SERVICE), programProperties.getProperty(PropertiesNames.MIME_TYPE), programProperties.getProperty(PropertiesNames.RESPONSE_FORMAT), Integer.parseInt(programProperties.getProperty(PropertiesNames.NUMBER_OF_THREADS))); processingDocuments.ProcessData(); File directory = new File(programProperties.getProperty(PropertiesNames.ANNOTATED_FOLDER)); listOfAllAnnotatedFiles = FileUtils.listFiles(directory, new RegexFileFilter("^(.*?)"), DirectoryFileFilter.DIRECTORY); RepoManager repoManager = new RepoManager(programProperties.getProperty(PropertiesNames.REPOSITORY_URL)); JsonToRDF jsonToRdfParser = new JsonToRDF(programProperties.getProperty(PropertiesNames.MIME_TYPE), programProperties.getProperty(PropertiesNames.RDFIZE_FOLDER)); for (File file : listOfAllAnnotatedFiles) { String fileContent = null; try { fileContent = FileUtils.readFileToString(file, "UTF-8"); } catch (IOException e) { logger.error(e); } Model graph = jsonToRdfParser.wirteDataToRDF(fileContent, file.getName(), programProperties.getProperty(PropertiesNames.RDFIZE_FOLDER)); try { repoManager.sendDataTOGraphDB(graph); } catch (RepositoryException e) { logger.error(e); } } repoManager.close(); }
From source file:de.tsystems.mms.apm.performancesignature.PerformanceSignaturePlugin.java
@Initializer(after = JOB_LOADED) public static void init1() throws IOException, InterruptedException { // Check for old dashboard configurations for (AbstractProject<?, ?> job : PerfSigUtils.getInstanceOrDie().getAllItems(AbstractProject.class)) { FilePath jobPath = new FilePath(job.getConfigFile().getFile()).getParent(); if (jobPath == null) continue; for (FilePath file : jobPath.list(new RegexFileFilter(".*-config.json"))) { file.delete();//from www . j av a 2s. co m } } }
From source file:muffinc.yafdivj.helper.FeretHandler.java
public static void move() { File file = new File(FOLDER); Path path = file.toPath();//from ww w. j av a 2 s . c o m FileFilter fileFilter = new RegexFileFilter("0\\d{4}f.*tif"); for (File file1 : file.listFiles(fileFilter)) { move(file1); } }
From source file:com.wipro.ats.bdre.tdimport.FileScan.java
public static void scanAndAddToQueue() { try {/* w w w .j ava2 s . co m*/ String scanDir = TDImportRunnableMain.getMonitoredDirName(); LOGGER.debug("Scanning directory: " + scanDir); File dir = new File(scanDir); if (!dir.exists()) { LOGGER.info("Created monitoring dir " + dir + " success=" + dir.mkdirs()); } File arcDir = new File(scanDir + "/" + TDImportRunnableMain.ARCHIVE); if (!arcDir.exists()) { LOGGER.info("Created monitoring dir " + arcDir + " success=" + arcDir.mkdirs()); } // Getting list of files recursively from directory except '_archive' directory Collection<File> listOfFiles = FileUtils.listFiles(dir, new RegexFileFilter(TDImportRunnableMain.getFilePattern()), new RegexFileFilter("^(?:(?!" + TDImportRunnableMain.ARCHIVE + ").)*$")); String fileName = ""; FileCopyInfo fileCopyInfo = null; for (File file : listOfFiles) { fileName = file.getName(); LOGGER.debug("Matched File Pattern by " + fileName); fileCopyInfo = new FileCopyInfo(); fileCopyInfo.setFileName(fileName); fileCopyInfo.setSubProcessId(TDImportRunnableMain.getSubProcessId()); LOGGER.debug("subprocessid in file scan =" + TDImportRunnableMain.getSubProcessId() + " " + fileCopyInfo.getSubProcessId()); fileCopyInfo.setSrcLocation(file.getAbsolutePath()); fileCopyInfo.setTdTable(TDImportRunnableMain.getTdTable()); fileCopyInfo.setFileSize(file.length()); fileCopyInfo.setTimeStamp(file.lastModified()); fileCopyInfo.setTdDB(TDImportRunnableMain.getTdDB()); fileCopyInfo.setTdUserName(TDImportRunnableMain.getTdUserName()); fileCopyInfo.setTdPassword(TDImportRunnableMain.getTdPassword()); fileCopyInfo.setTdDelimiter(TDImportRunnableMain.getTdDelimiter()); fileCopyInfo.setTdTpdid(TDImportRunnableMain.getTdTpdid()); FileMonitor.addToQueue(fileName, fileCopyInfo); } } catch (Exception err) { LOGGER.error("Error in scan directory ", err); throw new BDREException(err); } }
From source file:com.wipro.ats.bdre.filemon.FileScan.java
public static void scanAndAddToQueue() { try {//from w w w . j av a 2s . c om String scanDir = FileMonRunnableMain.getMonitoredDirName(); LOGGER.debug("Scanning directory: " + scanDir); File dir = new File(scanDir); if (!dir.exists()) { LOGGER.info("Created monitoring dir " + dir + " success=" + dir.mkdirs()); } File arcDir = new File(scanDir + "/" + FileMonRunnableMain.ARCHIVE); if (!arcDir.exists()) { LOGGER.info("Created monitoring dir " + arcDir + " success=" + arcDir.mkdirs()); } // Getting list of files recursively from directory except '_archive' directory Collection<File> listOfFiles = FileUtils.listFiles(dir, new RegexFileFilter(FileMonRunnableMain.getFilePattern()), new RegexFileFilter("^(?:(?!" + FileMonRunnableMain.ARCHIVE + ").)*$")); String fileName = ""; FileCopyInfo fileCopyInfo = null; for (File file : listOfFiles) { fileName = file.getName(); LOGGER.debug("Matched File Pattern by " + fileName); fileCopyInfo = new FileCopyInfo(); fileCopyInfo.setFileName(fileName); fileCopyInfo.setSubProcessId(FileMonRunnableMain.getSubProcessId()); fileCopyInfo.setServerId(Integer.toString(123461)); fileCopyInfo.setSrcLocation(file.getAbsolutePath()); fileCopyInfo.setDstLocation(file.getParent().replace(FileMonRunnableMain.getMonitoredDirName(), FileMonRunnableMain.getHdfsUploadDir())); fileCopyInfo.setFileHash(DigestUtils.md5Hex(FileUtils.readFileToByteArray(file))); fileCopyInfo.setFileSize(file.length()); fileCopyInfo.setTimeStamp(file.lastModified()); FileMonitor.addToQueue(fileName, fileCopyInfo); } } catch (Exception err) { LOGGER.error("Error in scan directory ", err); throw new BDREException(err); } }
From source file:biz.paluch.maven.configurator.FileTemplating.java
/** * Process files which match the template pattern. Creates a new file using the input file with property * replacement. Target filename is without the template name part. * * @param log/*www . j a va2s. c om*/ * @param root * @param processor * @throws IOException */ public static void processFiles(Log log, File root, TemplateProcessor processor) throws IOException { Iterator<File> iterator = FileUtils.iterateFiles(root, new RegexFileFilter(FILE_TEMPLATE_PATTERN), TrueFileFilter.TRUE); while (iterator.hasNext()) { File next = iterator.next(); log.debug("Processing file " + next); try { processor.processFile(next, getTargetFile(next)); } catch (IOException e) { throw new IOException("Cannot process file " + next.toString() + ": " + e.getMessage(), e); } } }