List of usage examples for org.apache.commons.io.comparator LastModifiedFileComparator LastModifiedFileComparator
LastModifiedFileComparator
From source file:com.jaeksoft.searchlib.parser.PdfParser.java
@Override public void mergeFiles(File fileDir, File destFile) throws SearchLibException { PDFMergerUtility pdfMerger = new PDFMergerUtility(); File[] files = new LastModifiedFileComparator().sort(fileDir.listFiles()); for (File file : files) { String ext = FilenameUtils.getExtension(file.getName()); if (!"pdf".equalsIgnoreCase(ext)) continue; pdfMerger.addSource(file);//w w w . ja v a 2s .co m } if (destFile.exists()) destFile.delete(); pdfMerger.setDestinationFileName(destFile.getAbsolutePath()); try { pdfMerger.mergeDocuments(); } catch (COSVisitorException e) { throw new SearchLibException(e); } catch (IOException e) { throw new SearchLibException(e); } }
From source file:org.pitest.maven.report.ReportSourceLocator.java
private File executeLocator(File reportsDirectory, Log log) { File[] subdirectories = reportsDirectory.listFiles(TIMESTAMPED_REPORTS_FILE_FILTER); File latest = reportsDirectory; log.debug("ReportSourceLocator starting search in directory [" + reportsDirectory.getAbsolutePath() + "]"); if (subdirectories != null) { LastModifiedFileComparator c = new LastModifiedFileComparator(); for (File f : subdirectories) { log.debug("comparing directory [" + f.getAbsolutePath() + "] with the current latest directory of [" + latest.getAbsolutePath() + "]"); if (c.compare(latest, f) < 0) { latest = f;/* w ww . ja v a 2 s .co m*/ log.debug("directory [" + f.getAbsolutePath() + "] is now the latest"); } } } else { throw new PitError("could not list files in directory [" + reportsDirectory.getAbsolutePath() + "] because of an unknown I/O error"); } log.debug("ReportSourceLocator determined directory [" + latest.getAbsolutePath() + "] is the directory containing the latest pit reports"); return latest; }