Java File Path Delete deleteFolder(String folderPath)

Here you can find the source of deleteFolder(String folderPath)

Description

delete Folder

License

Open Source License

Declaration

private static void deleteFolder(String folderPath) 

Method Source Code

//package com.java2s;

import java.io.File;

public class Main {
    private static void deleteFolder(String folderPath) {
        File file = new File(folderPath);
        if (!file.exists()) {
            return;
        }/*from  w w  w  . j  ava2s . com*/
        if (!recursiveDeleteDirContenteleteDir(file)) {
            System.err.println("Failed to clean up old resources in " + folderPath
                    + " while setting up additional test resources.");
        }
    }

    public static boolean recursiveDeleteDirContenteleteDir(File dir) {
        if (dir.isDirectory()) {
            String[] children = dir.list();
            for (int i = 0; i < children.length; i++) {
                boolean success = recursiveDeleteDirContenteleteDir(new File(dir, children[i]));
                if (!success) {
                    return false;
                }
            }
        }
        return dir.delete();
    }
}

Related

  1. deleteFolder(File path)
  2. deleteFolder(File path)
  3. deleteFolder(String filePath)
  4. deleteFolder(String folderPath)
  5. deleteFolder(String folderPath)
  6. deleteFolder(String path)
  7. deleteFolder(String path)
  8. deleteFolder(String path)
  9. deleteFolder(String path)