Deleting a txt file using java code before creating and adding new output -


I am a novice programmer and trying to delete a text file from my desktop using Java from Java Java, but it is not working. I have a command that creates a text file and adds output to this text file all the time, but whenever the Java Svallet page reloads I want to delete this text file.

  string outputFile = "C: \\ user \\ aookpidi \\ desktop \\ output.txt"; {File file = new file (output file); If (file.delete ()) {//System.out.println(file + "has been deleted!"); System.out.println (file.getName () + "has been deleted!"); } Else {System.out.println ("The removal operation failed."); }} Hold (exception e) {e.printStackTrace (); }  


Comments