First, it needs to be clear that the delete () method in the file class applies to deleting an empty directory, or a single file.
Then, the deletion of folders above the level two directory needs to be removed in two steps.
1. Delete the file below the bottom directory, or empty directory
When there are multiple files, you need to loop to delete the following code:
New File (scriptdir); if (File_scriptdir.exists () | | file_scriptdir.isdirectory ()) { = file_scriptdir.list (); if (children.length>0) { for (int i=0;i<children.length;i++) { New File (file_scriptdir,children[i]). Delete ();} }}
2. Delete the parent directory, and the directory is empty
When you delete an empty directory, you can use the Delete () method directly.
Finally, if you are running in a Linux environment, you can use the command line, but there are also requirements for folders.
Java implementation delete files and folders