Here you can find the source of deleteDir(File directory)
Parameter | Description |
---|---|
directory | a parameter |
public final static boolean deleteDir(File directory)
//package com.java2s; /**// ww w. j a va 2 s . co m * This file is part of Waarp Project. * * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the * COPYRIGHT.txt in the distribution for a full listing of individual contributors. * * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * * Waarp 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 General * Public License for more details. * * You should have received a copy of the GNU General Public License along with Waarp . If not, see * <http://www.gnu.org/licenses/>. */ import java.io.File; public class Main { /** * Delete the directory associated with the File as path if empty * * @param directory * @return True if deleted, False else. */ public final static boolean deleteDir(File directory) { if (directory == null) { return true; } if (!directory.exists()) { return true; } if (!directory.isDirectory()) { return false; } return directory.delete(); } /** * Delete physically the file * * @param file * @return True if OK, else if not (or if the file never exists). */ public final static boolean delete(File file) { if (!file.exists()) { return true; } return file.delete(); } }