Example usage for org.apache.commons.io.filefilter FileFilterUtils ageFileFilter

List of usage examples for org.apache.commons.io.filefilter FileFilterUtils ageFileFilter

Introduction

In this page you can find the example usage for org.apache.commons.io.filefilter FileFilterUtils ageFileFilter.

Prototype

public static IOFileFilter ageFileFilter(File cutoffReference) 

Source Link

Document

Returns a filter that returns true if the file was last modified after the specified reference file.

Usage

From source file:info.magnolia.ui.framework.command.CleanTempFilesCommand.java

@Override
public boolean execute(final Context context) throws Exception {
    String tmpDirPath = configurationProperties.getProperty("magnolia.upload.tmpdir");
    File tmpDir = new File(tmpDirPath);
    Date date = DateUtils.addHours(new Date(), TIME_OFFSET_IN_HOURS); // current time minus 12 hours
    Iterator<File> files = FileUtils.iterateFiles(tmpDir, FileFilterUtils.ageFileFilter(date),
            FileFilterUtils.ageFileFilter(date));
    while (files.hasNext()) {
        files.next().delete();/*from ww w.j  a  va  2s . c om*/
    }
    return true;
}