Java File Path Delete deleteDirectory(String path)

Here you can find the source of deleteDirectory(String path)

Description

delete Directory

License

Open Source License

Declaration

public static boolean deleteDirectory(String path) 

Method Source Code

//package com.java2s;
/**//from   www.  j  a  v a2  s.c o m
 * Copyright (c) 2015 SK holdings Co., Ltd. All rights reserved.
 * This software is the confidential and proprietary information of SK holdings.
 * You shall not disclose such confidential information and shall use it only in
 * accordance with the terms of the license agreement you entered into with SK holdings.
 * (http://www.eclipse.org/legal/epl-v10.html)
 */

import java.io.File;

public class Main {

    public static boolean deleteDirectory(String path) {
        boolean isOk = false;
        try {
            File dir = new File(path);

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

            }

            return dir.delete();
        } catch (Exception localException) {
            isOk = false;
        }
        return isOk;
    }
}

Related

  1. deleteDirectory(String dirPath)
  2. deleteDirectory(String dirPath)
  3. deleteDirectory(String filePath)
  4. deleteDirectory(String path)
  5. deleteDirectory(String path)
  6. deleteDirectory(String path)
  7. deleteDirectory(String path)
  8. deleteDirectory(String path)
  9. deleteDirectory(String path)