/** * IOFileFilter <br> * Created on: Nov 29, 2012 9:32:51 AM * * @param filePath * @param fileFilter * @return */ public static Collection<File> getFiles(String filePath, IOFileFilter fileFilter) { NameFileComparator comp = new NameFileComparator(); File[] fileArr = comp.sort( FileUtils.convertFileCollectionToFileArray( FileUtils.listFiles((new File(filePath)), fileFilter, TrueFileFilter.INSTANCE))); comp = null; return new LinkedList<File>(Arrays.asList(fileArr)); }
/** * Suffix <br> * Created on: Nov 28, 2012 1:50:50 PM * * @param filePath * @param nameFix * @param newerTime * @param isOlder true : all file ,false : newer file * @return */ public static Collection<File> getSuffixAndNewerFiles( String filePath, String nameFix, long newerTime, boolean isOlder) { IOFileFilter wildcardFileFilter = new SuffixFileFilter(nameFix); IOFileFilter ageFileFilter = new AgeFileFilter(newerTime, isOlder); IOFileFilter andFilter = FileFilterUtils.and(wildcardFileFilter, ageFileFilter); NameFileComparator comp = new NameFileComparator(); File[] fileArr = comp.sort( FileUtils.convertFileCollectionToFileArray( FileUtils.listFiles((new File(filePath)), andFilter, TrueFileFilter.INSTANCE))); comp = null; return new LinkedList<File>(Arrays.asList(fileArr)); }
public static File[] convertFileCollectionToFileArray(Collection files) { return FileUtils.convertFileCollectionToFileArray(files); }