Java File Path Delete deleteDir(File dir)

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

Description

delete Dir

License

Open Source License

Declaration

public static void deleteDir(File dir) throws IOException 

Method Source Code

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

import java.io.File;

import java.io.IOException;

public class Main {

    public static void deleteDir(File dir) throws IOException {
        if (dir.isFile())
            throw new IOException("IOException -> BadInputException: not a directory.");
        File[] files = dir.listFiles();
        if (files != null) {
            for (int i = 0; i < files.length; i++) {
                File file = files[i];
                if (file.isFile()) {
                    file.delete();//from  ww w . j a va  2  s . c om
                } else {
                    deleteDir(file);
                }
            }
        } // if
        dir.delete();
    }
}

Related

  1. deleteDir(File dir)
  2. deleteDir(File dir)
  3. deleteDir(File dir)
  4. deleteDir(File dir)
  5. deleteDir(File dir)
  6. deleteDir(File dir)
  7. deleteDir(File dir)
  8. deleteDir(File dir)
  9. deleteDir(File dir)