Cannot delete folder using Java

前端 未结 4 890
孤城傲影
孤城傲影 2021-01-22 17:20

I am trying to delete a folder which has only files but no sub folders without success.

Code:

File rowFolder = new File(folderPath);
String[] files = r         


        
4条回答
  •  旧时难觅i
    2021-01-22 17:42

    As you aren't checking the return value of delete(), the output you produce is meaningless. The deletion could have failed for any number of reasons:

    • the file is a non-empty directory
    • the file is open by another user (on some platforms)
    • you don't have permission to delete that file.

提交回复
热议问题