I want to develop a tool which can delete all files of a folder 2 times a day - at 8:30 in morning and night. It should only delete all files permanently but not the folder.
My deletion code is working fine but I am having problem with scheduling. I have no idea how to write a scheduler code. Can anyone help me with the right code to schedule it?
public class Delete
{
public static void main(String[] args)
{
try
{
Files.deleteIfExists(Paths.get("C:\\Users\\Dekstop\\Dummy"));
//I want to delete all Files not the Folder
}
catch(NoSuchFileException e)
{
System.out.println("No such file/directory exists");
}
catch(DirectoryNotEmptyException e)
{
System.out.println("Directory is not empty.");
}
catch(IOException e)
{
System.out.println("Invalid permissions.");
}
System.out.println("Deletion successful.");
}
}