not able to delete the directory through Java

后端 未结 5 1516
执念已碎
执念已碎 2021-02-13 06:59

In my application I have written the code to delete the directory from drive but when I inspect the delete function of File it doesn\'t delete the file. I have written some thin

5条回答
  •  北海茫月
    2021-02-13 07:39

    Why to invent a wheel with methods to delete recursively? Take a look at apache commons io. https://commons.apache.org/proper/commons-io/javadocs/api-1.4/

    FileUtils.deleteDirectory(dir);
    

    OR

    FileUtils.forceDelete(dir);
    

    That is all you need. There is also plenty of useful methods to manipulate files...

提交回复
热议问题