Posts which you will also like.

Saturday, October 15, 2011

Deleting a non empty directory using JAVA

Here in this post I created a java program which deletes the directories which are non empty.
In this program I have used recursion approach to delete the directory which is not empty.Program continuously searches the bottom most folder in directory tree deletes it then return back to its parent and deletes it.This process is completed when recursion reaches the root directory i.e parent folder of all child folder.Delete that parent folder and we are done.

  Download Source Code for this Application: DelDir.rar


  1. There are some folders which say "access Denied"..
    Can it delete such folders..??

  2. Hi Anuj
    We can certainly delete the files with access denied prompt but it requires sophisticated java api and this simple program is just a demo with core api of java.


Your comment may wait for moderation.... Protected by Copyscape Online Plagiarism Tool