I want my code to empty a specific text file, when it is the beginning of each month. I have this code but it doesn't seem to work, do I have something wrong with the syntax maybe?
public void monthlyCleanse(File f){
LocalDate localDate = LocalDate.now();
String d = DateTimeFormatter.ofPattern("dd").format(localDate);
System.out.println(d);
if(d.equals("01")){
"filename.txt".replace(toString().valueOf(f), "");
}
}
As you can see I am changing the format to only show the day of the month, then I am checking if that day equals "01" then do something...which is to empty a text file.
Then i am calling it here...
monthlyCleanse(new File("filename.txt"));
How can i make sure that this file is emptied?