Here you can find the source of delTree(String path)
public static boolean delTree(String path)
//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(); } }