Here you can find the source of deleteAll(File path)
public static void deleteAll(File path)
//package com.java2s; /******************************************************************************* * Copyright (c) 2008 Red Hat, Inc. /*from ww w .j av a 2s . c om*/ * Distributed under license by Red Hat, Inc. All rights reserved. * This program is 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 * * Contributors: * Red Hat, Inc. - initial API and implementation ******************************************************************************/ import java.io.File; public class Main { public static void deleteAll(File path) { if (!path.exists()) return; if (path.isFile()) { path.delete(); return; } File[] files = path.listFiles(); for (int i = 0; i < files.length; i++) { deleteAll(files[i]); } path.delete(); } }