Here you can find the source of deleteDir(File delDir)
Parameter | Description |
---|---|
delDir | The directory to delelte |
public static boolean deleteDir(File delDir)
//package com.java2s; /*// w ww.j ava 2s . c om * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * * Copyright (C) 2006-2010 Adele Team/LIG/Grenoble University, France */ import java.io.File; public class Main { /** * Util: Deletes recursively the given directory. * * @param delDir * The directory to delelte * @return true if the directory is successfully deleted; false otherwise */ public static boolean deleteDir(File delDir) { if (!delDir.exists()) return true; File[] allDelFiles = delDir.listFiles(); if (allDelFiles != null) for (int iF = 0; iF < allDelFiles.length; iF++) { if (allDelFiles[iF].isDirectory()) deleteDir(allDelFiles[iF]); else allDelFiles[iF].delete(); } return delDir.delete(); } }