Java Utililty Methods File Delete nio

List of utility methods to do File Delete nio

Description

The list of methods to do File Delete nio are organized into topic(s).

Method

voiddelete(File f)
delete
if (f.isDirectory() && !Files.isSymbolicLink(Paths.get(f.toURI()))) {
    for (File c : f.listFiles()) {
        delete(c);
f.delete();
voiddelete(File file)
Deletes a file recursively.
if (file.isDirectory()) {
    File[] children = file.listFiles();
    if (children == null) {
        String msg = "Could not access content of " + file.getAbsolutePath();
        throw new IOException(msg);
    for (File f : children)
        delete(f);
...
booleandelete(File file)
delete
return delete(file.toPath());
voiddelete(File file)
delete
if (file.isFile()) {
    deleteQuietly(file);
} else if (file.isDirectory()) {
    Path directory = file.toPath();
    try {
        Files.walkFileTree(directory, new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
...
booleandelete(File file)
delete
if (!file.exists())
    return true;
try {
    final FileSystem fileSystem = FileSystems.getDefault();
    final Path path = fileSystem.getPath(file.getAbsolutePath());
    Files.delete(path);
    return true;
} catch (FileSystemException e) {
...
voiddelete(File file)
delete
for (int n = 0; n < 10; n++) {
    try {
        Files.delete(file.toPath());
        if (Files.exists(file.toPath())) {
            Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
            continue;
        return;
...
voiddelete(File file)
Recursively delete a file or directory.
if (!file.exists())
    return;
if (file.isDirectory()) {
    for (File child : listFiles(file)) {
        delete(child);
Files.delete(file.toPath());
...
voiddelete(File file)
delete
if (file.isDirectory()) {
    deleteDirectory(file);
    return;
Files.delete(Paths.get(file.getPath()));
voiddelete(File toRecurse)
delete
Files.walk(toRecurse.toPath(), FileVisitOption.FOLLOW_LINKS).sorted(Comparator.reverseOrder())
        .map(Path::toFile).forEach(File::delete);
voiddelete(final File directory, final FileFilter fileFilter)
delete
if (!directory.exists() || !directory.isDirectory())
    throw new FileNotFoundException("No directory found at " + directory);
for (File file : directory.listFiles(fileFilter))
    Files.delete(file.toPath());