Java File Path Delete delTree(String path)

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

Description

del Tree

License

MIT License

Declaration

public static boolean delTree(String path) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *  Copyright ? 2012-2015 eBay Software Foundation
 *  This program is dual licensed under the MIT and Apache 2.0 licenses.
 *  Please see LICENSE for more information.
 *******************************************************************************/

import java.io.File;

public class Main {
    public static boolean delTree(String path) {
        File pathFile = new File(path);
        if (!pathFile.exists())
            return true;
        File[] files = pathFile.listFiles();
        for (int i = 0; i < files.length; i++) {
            if (files[i].isDirectory())
                delTree(files[i].getAbsolutePath());
            else {
                files[i].delete();/*  ww w  .j av a2 s  .  co m*/
            }
        }
        return pathFile.delete();
    }
}

Related

  1. DelFile(String in_Path, ArrayList arrFileList)
  2. delFile(String path)
  3. delFile(String pathName)
  4. delFileIfExists(String path)
  5. delFiles(String path)