Here you can find the source of deleteFile(final File file)
Parameter | Description |
---|---|
file | the path of the directory to be deleted |
public static boolean deleteFile(final File file)
//package com.java2s; /*========================================================================= //w w w .j a v a 2s . co m Copyright ? 2013 BIREME/PAHO/WHO This file is part of TabNetCells. TabNetCells is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. TabNetCells is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with TabNetCells. If not, see <http://www.gnu.org/licenses/>. =========================================================================*/ import java.io.File; public class Main { /** * deletes recursevelly a directory * @param file the path of the directory to be deleted * @return true is the directory was deleted or false if not */ public static boolean deleteFile(final File file) { if (file == null) { throw new NullPointerException("file"); } boolean status = true; if (file.isDirectory()) { for (File child : file.listFiles()) { status = status && deleteFile(child); } } return status && file.delete(); } }