Deletes files recursively.
@param files the files to delete
@throws IOException if a file could not be deleted
489436
public static void deleteFilesRecursively( File... files ) throws IOException {

		if( files == null )
			return;

		List<File> filesToDelete = new ArrayList<> ();
		filesToDelete.addAll( Arrays.asList( files ));
		while( ! filesToDelete.isEmpty()) {
			File currentFile = filesToDelete.remove( 0 );
			if( currentFile == null
					|| ! currentFile.exists())
				continue;

			// Non-empty directory: add sub-files and reinsert the current directory after
			File[] subFiles = currentFile.listFiles();
			if( subFiles != null && subFiles.length > 0 ) {
				filesToDelete.add( 0, currentFile );
				filesToDelete.addAll( 0, Arrays.asList( subFiles ));
			}

			// Existing file or empty directory => delete it
			else if( ! currentFile.delete())
				throw new IOException( currentFile.getAbsolutePath() + " could not be deleted." );
		}
	}
1155176
public void delete() throws IOException {
        close();
        if (osFile != null) {
            boolean deleted = osFile.delete();
            while (!deleted) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                    logger.error("{} not deleted.", osFile);
                }
                System.gc();
                deleted = osFile.delete();
            }
        }
    }
50012
public static void deleteRecursively(Path path) throws IOException {
        if (Files.isDirectory(path)) {
            Files.list(path).forEach(file -> {
                try {
                    deleteRecursively(file);
                } catch (IOException e) {
                    throw new UncheckedIOException(e.getMessage(), e);
                }
            });
        }
        Files.delete(path);
    }
265990
public static void deleteFileOrDir(File file) throws IOException {
	if (file.isDirectory()) {
	    File[] children = file.listFiles();
	    if (children != null) {
		for (File child : children) {
		    deleteFileOrDir(child);
		}
	    }
	}
	if (!file.delete()) {
	    throw new IOException("Could not remove '" + file + "'!");
	}
    }
292376
private static void deleteIfExists(Path path) throws IOException {
		FileSystem fs = path.getFileSystem();
		if (fs.exists(path)) {
			fs.delete(path, true);
		}
	}
107358
public static void deleteRecursively(File file) {
        if (file.isDirectory()) {
            for (File c : file.listFiles()) {
                deleteRecursively(c);
            }
        }
        if (!file.delete()) {
            System.err.println("WARN: unable to delete file: " + file.getPath());
        }
    }
226492
@Override
  public Value<Void> run(List<GcsFilename> files) throws Exception {
    for (GcsFilename file : files) {
      try {
        gcs.delete(file);
      } catch (RetriesExhaustedException | IOException e) {
        log.log(Level.WARNING, "Failed to cleanup file: " + file, e);
      }
    }
    return null;
  }
897496
public static void copyFiles(String[] files, String storageFolder) throws IOException {
        copyFiles(getFiles(files), storageFolder);
    }
1107963
public static void deleteDirectory(File fileOrDirectory) {
        if (fileOrDirectory.isDirectory())
            for (File child : fileOrDirectory.listFiles())
                deleteDirectory(child);

        fileOrDirectory.delete();
    }
753052
public void delete() {
    try {
      Files.deleteIfExists(file.file().toPath());
    } catch (IOException e) {
      throw new StorageException(e);
    }
  }
1274277
public static void deleteFile(@Nonnull File f) throws IOException {
        newPathRemover(PathRemover.PathChecker.ALLOW_ALL).forceRemoveFile(fileToPath(f));
    }
336879
@Override
    public void run() {
        Collections.sort(files);
        for (int i = files.size() - 1; i >= 0; i--) {
            new File(files.get(i)).delete();
        }
    }
114335
private void delete(File file) {
		if (file.isDirectory()) {
			File[] children = file.listFiles();
			for (File child : children) {
				delete(child);
			}
		}
		if (!file.delete()) {
			if (!file.isDirectory()) {
				logger.warn("Unable to clean/delete file: {}", file);
			} else {
				logger.debug("Unable to clean/delete directory: {}", file);
			}
		}
	}
426179
private void deleteEntryFiles(List<Entry<V>> list) throws IOException {
    for(Entry<V> e: list) {
      File file = e.getFile();
      if(file != null && file.exists()) {
        if (file.delete()) {
          _log.info(file.getName() + " deleted");
        } else {
          _log.warn(file.getName() + " not deleted");
        }
      }
    }
  }
1047901
public static void delete(final Path target) throws IOException {
		if(target != null && Files.exists(target)) {
			Files.walkFileTree(target, new SimpleFileVisitor<Path>() {
				@Override
				public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
					Files.delete(file);
					return super.visitFile(file, attrs);
				}

				@Override
				public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
					Files.delete(dir);
					return super.postVisitDirectory(dir, exc);
				}
			});
		}
	}
68094
@Override
  public void delete() {
    LOGGER.debug("Deleting {}", this);
    Path path = file.file().toPath();
    if (Files.exists(path)) {
      try {
        Files.delete(file.file().toPath());
      } catch (IOException e) {
      }
    }
  }
601042
public static void removeDirectory(File dir) throws IOException
   {
      if (dir.isDirectory())
      {
         for (File subFile : dir.listFiles())
         {
            removeDirectory(subFile);
         }

         if (!dir.delete())
         {
            throw new IOException("Can't remove folder : " + dir.getCanonicalPath());
         }
      }
      else
      {
         if (!dir.delete())
         {
            throw new IOException("Can't remove file : " + dir.getCanonicalPath());
         }
      }
   }