public static boolean fullyDeleteContents(File dir) throws IOException {
        boolean deletionSucceeded = true;
        File[] contents = dir.listFiles();
        if (contents != null) {
            for (int i = 0; i < contents.length; i++) {
                if (contents[i].isFile()) {
                    if (!contents[i].delete()) {
                        deletionSucceeded = false;
                    }

                } else {
                    if (contents[i].delete()) {
                        continue;
                    }

                    if (!fullyDelete(contents[i])) {
                        deletionSucceeded = false;
                    }
                }
            }
        }
        return deletionSucceeded;
    }
Delete the contents of files and subdirectories in the specified directory

@param dir            the specified directory
@return               the deleted count
@throws IOException   the exception while deleting contents
inlong-tubemq/tubemq-server/src/main/java/org/apache/inlong/tubemq/server/common/utils/FileUtil.java