All Downloads are FREE. Search and download functionalities are using the official Maven repository.

co.arcs.groove.basking.task.DeleteTemporariesTask Maven / Gradle / Ivy

There is a newer version: 1.7.2
Show newest version
package co.arcs.groove.basking.task;

import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;

import co.arcs.groove.basking.SyncService;

public class DeleteTemporariesTask implements Task {

    private final File tempPath;

    public DeleteTemporariesTask(File tempPath) {
        this.tempPath = tempPath;
    }

    @Override
    public Void call() throws Exception {

        File[] tempFiles = tempPath.listFiles(new FilenameFilter() {

            @Override
            public boolean accept(File arg0, String arg1) {
                return arg1.endsWith(SyncService.TEMP_FILE_EXTENSION_1) || arg1.endsWith(SyncService.TEMP_FILE_EXTENSION_2);
            }
        });
        for (File f : tempFiles) {
            if (!f.delete()) {
                throw new IOException("Could not delete temp file: '" + f.getAbsolutePath() + "'");
            }
        }
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy