Java Directory Delete nio deleteDir(File file)

Here you can find the source of deleteDir(File file)

Description

delete Dir

License

Open Source License

Declaration

public static void deleteDir(File file) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

public class Main {
    public static void deleteDir(File file) {
        File[] files = file.listFiles();
        if (files != null) {
            for (File temp : files) {
                deleteDir(temp);//from w  w w  .j a va  2 s . c  o m
            }
        }
        try {
            Files.deleteIfExists(file.toPath());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related

  1. deleteDir(File dir)
  2. deleteDir(final File targetDir)
  3. deleteDir(String dirName)
  4. deleteDir(String path)
  5. deleteDirectory(File dir)