Follow Algorithms & Datastructures content from CodingCreek.com and Join Java Community Java Q&A

Delete a File in Java

To delete a file in Java, get the file handle to the file that you want to delete. To delete a file in particular directory, Construct File Path to that file, get the file handle to delete the file using the path. Use File.delete() from IO library to delete the file. delete() method will return true, if file is deleted successfully, otherwise, it will return false.

File Delete

References

https://docs.oracle.com/javase/8/docs/api/java/io/File.html