Delete Directory Java Program

Hi everyone!! You will learn delete directory java program in the following post.

Using delete method we can delete the directory. But the directory should be empty in order to delete it.

If the directory contains a lot of subdirectories and files then we have to use recursive delete in order to delete all subdirectories and files.

Example: Delete Directory Java Program

Delete Directory Java Program

Also Read – Create Directory Java Program


public class Delete_Directory {

public static void main(String[] args) {

File fl = new File("C://DeleteDirectory/demo_delete.txt");

boolean bl_Delete = fl.delete();

System.out.println("To check the file deleted True/False: " + bl_Delete);



To check the file deleted True/False: true

About the author


View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *