Here you can find the source of deleteRecursively(File f)
private static void deleteRecursively(File f) throws IOException
//package com.java2s; /******************************************************************************* * 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 * * Contributors://from w w w . ja v a 2s .c om * IBM Corporation - initial API and implementation *******************************************************************************/ import java.io.File; import java.io.IOException; public class Main { private static void deleteRecursively(File f) throws IOException { if (f.isDirectory()) { for (String s : f.list()) { deleteRecursively(new File(f, s)); } } boolean b = f.delete(); if (!b) { throw new IOException("failed to delete " + f); } } }