I want to pick only those files which have "txt
" extension and are more than 1 minute old. Is there a way to enforce both of these conditions in the listFiles
method?
To ensure it picks only txt files, this is how I did
Collection<File> myFiles = FileUtils.listFiles(FileUtils.getFile(inputPath),
FileFilterUtils.suffixFileFilter(".txt"),
null);
I could find isFileOlder()
method in FileUtils
but how to impose both restrictions to it?
Please suggest some way.
You want to use the AndFileFilter.
This lets you combine any two file filters as a Boolean. As there isn't a delivered file filter for the age criteria, you'll still need to create one, following the lines of the other comment.