Java Delete Folder deleteFolder(File folder)

Here you can find the source of deleteFolder(File folder)

Description

delete Folder

License

Open Source License

Declaration

public static void deleteFolder(File folder) throws IOException 

Method Source Code

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

import java.io.*;

public class Main {
    public static void deleteFolder(File folder) throws IOException {

        if (!folder.exists())
            throw new IOException("" + folder + " doesn't exist.");
        if (!folder.isDirectory())
            throw new IOException("" + folder + " is not a folder.");
        for (File fileOrFolder : folder.listFiles()) {
            if (fileOrFolder.isDirectory()) {
                deleteFolder(fileOrFolder);
                fileOrFolder.delete();/* w  w w .  java 2  s.c  o m*/
            } else
                fileOrFolder.delete();
        }
        folder.delete();

    }
}

Related

  1. deleteFolder(File folder)
  2. deleteFolder(File folder)
  3. deleteFolder(File folder)
  4. deleteFolder(File folder)
  5. deleteFolder(File folder)
  6. deleteFolder(File folder)
  7. deleteFolder(File folder)
  8. deleteFolder(final File folder)
  9. deleteFolder(final File folder)