private static void recursiveDelete(File file) throws IOException {
        if (file != null && file.exists()) {
            File[] files = file.listFiles();
            if (files != null) {
                for (int i = 0; i < files.length; i++) {
                    if (files[i].isDirectory()) {
                        recursiveDelete(files[i]);
                    } else if (!files[i].delete()) {
                        throw new IOException("Could not delete the file of: " + files[i]);
                    }
                }
            }

            if (!file.delete()) {
                throw new IOException("Could not delete the file of: " + file);
            }
        }
    }