I want to write a method where i can return Future instead of void start
Also i want to apply lock while deleting the file.
public static void start(Vertx vertx) throws Exception { vertx.setTimer(timeInterval, id -> { File file = new File(config.getStringProperty("file.upload.directory", null).get());
if (file.isDirectory()) {
File[] files = file.listFiles();
for (File fileName : files) {
long diff = new Date().getTime() - fileName.lastModified();
if (diff > config.getLongProperty("file.upload.cleanup.timer.millisecond", 0).get()) {
deleteFileUploads(fileName.getAbsolutePath());
}
}
}
});
}
private static void deleteFileUploads(String fileName) {
File file = new File(fileName);
LOGGER.debug("Name of the file to be deleted"+fileName);
file.delete();
}
}
Instead of this I want my function to be like public static Future start(Vertx vertx) throws Exception { }