Here you can find the source of deleteFolder(File file)
public static void deleteFolder(File file)
//package com.java2s; /******************************************************************************* * Copyright (c) 2009, 2010 Progress Software Corporation. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html ******************************************************************************/ import java.io.File; public class Main { public static void deleteFolder(File file) { if (!file.isDirectory() || (file.isDirectory() && file.list().length == 0)) { file.delete();/*from w w w .j a v a 2 s. co m*/ } else { File[] listFiles = file.listFiles(); for (File childFile : listFiles) { deleteFolder(childFile); } file.delete(); } } }