How to delete a file in Java.

In Java, we can delete a file by using the File.delete() method of File class. The delete() method deletes the file or directory denoted by the abstract pathname.

Code :