Here you can find the source of delTree(File file)
Parameter | Description |
---|---|
file | file or directory to delete |
public static boolean delTree(File file)
//package com.java2s; /**// w w w. ja v a 2 s .c om * Appframework * Copyright (C) 2003-2016 SSHTOOLS Limited * * This program 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 2 * of the License, or (at your option) any later version. */ import java.io.File; public class Main { /** * Delete either the supplied file or all <strong>files</strong> within the * directory supplied or any sub-directories. Directories will <strong>not</strong> * be deleted. * * @param file file or directory to delete * @return ok */ public static boolean delTree(File file) { if (file.isFile()) { return file.delete(); } File[] list = file.listFiles(); for (int i = 0; i < list.length; i++) { if (!delTree(list[i])) { return false; } } return true; } }