I'm trying to delete two repositories
org.apache.commons.io.FileUtils.deleteDirectory(jobInDirectory);
org.apache.commons.io.FileUtils.deleteDirectory(jobOutDirectory);
Path are right
Rights on directory too
The first is well deleted but not the second. Every file inside was deleted but not the directory
java.io.IOException: Unable to delete directory /opt/appdata/conv/data/out/Job000000000676.
I looked to see if another process had locked it using the command lsfo
and no other process uses it...
Any idea ?
Method 1: using delete() to delete files and empty folders Provide the path of a directory. Call user-defined method deleteDirectory() to delete all the files and subfolders.
In Java, to delete a non-empty directory, we must first delete all the files present in the directory. Then, we can delete the directory. In the above example, we have used the for-each loop to delete all the files present in the directory.
Java isn't able to delete folders with data in it. You have to delete all files before deleting the folder.
By using the File.delete() Method The delete() method of the File class is used for deleting a directory.
You need to check the following to fix this issue:-
User Id/account with which you are running your application must have permission to delete the below directory. If you are running the java application with your account then you must have permission to delete the below directory.
/opt/appdata/conv/data/out/Job000000000676
Add the account into the proper group. To do that first check with ls -ltr
execute it inside /opt/appdata/conv/data/out
and add your account to the group which has full permission to delete directories inside out
directory
Also check if Job000000000676
has sub directory inside it. In such a condition you can execute unix command like rm -rf /opt/appdata/conv/data/out/Job000000000676
. See how to execute unix command from java application for detail.
Hope this will help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With