more reliable Remove All

This commit is contained in:
2024-06-30 07:15:48 -05:00
parent a9f0fc3f4c
commit 2735c311ad
3 changed files with 14 additions and 18 deletions

View File

@@ -128,4 +128,16 @@ public class Main {
System.out.println(e.getMessage());
}
}
public static void deleteDir(File file) { // https://stackoverflow.com/a/29175213/9259829
File[] contents = file.listFiles();
if (contents != null) {
for (File f : contents) {
if (! Files.isSymbolicLink(f.toPath())) {
deleteDir(f);
}
}
}
file.delete();
}
}