FileUtils.deleteDirectoryContents(inputDir); inputDir.mkdirs();
/** * Recursively deletes a path. * * @param path the path delete, may exist or not * @throws IOException failed to delete the file / directory */ public static void deletePath(@NonNull final File path) throws IOException { if (!path.exists()) { return; } if (path.isDirectory()) { deleteDirectoryContents(path); } if (!path.delete()) { throw new IOException(String.format("Could not delete path '%s'.", path)); } }
/** * Makes sure {@code path} is an empty directory. If {@code path} is a directory, its contents * are removed recursively, leaving an empty directory. If {@code path} is not a directory, * it is removed and a directory created with the given path. If {@code path} does not * exist, a directory is created with the given path. * * @param path the path, that may exist or not and may be a file or directory * @throws IOException failed to delete directory contents, failed to delete {@code path} or * failed to create a directory at {@code path} */ public static void cleanOutputDir(@NonNull File path) throws IOException { if (!path.isDirectory()) { if (path.exists()) { deletePath(path); } if (!path.mkdirs()) { throw new IOException(String.format("Could not create empty folder %s", path)); } return; } deleteDirectoryContents(path); }
private static void deleteDirectoryContents(@NonNull File directory) throws IOException { if (!directory.exists()) { FileUtils.mkdirs(directory); } else if (!directory.isDirectory()) { FileUtils.delete(directory); FileUtils.mkdirs(directory); } else { FileUtils.deleteDirectoryContents(directory); } }
FileUtils.deleteDirectoryContents(localJarsLocation);
FileUtils.deleteDirectoryContents(outputFile);
backupJar.getAbsolutePath(), jarInput.getFile()); try { FileUtils.deleteDirectoryContents(backupJar); } catch(IOException e) { LOGGER.warning(String.format("Cannot delete %s : %s",
FileUtils.deleteDirectoryContents(getIncrementalFolder());