Here you can find the source of deleteEmptyDirs(File dir)
public static void deleteEmptyDirs(File dir) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2007, 2010 IBM Corporation and others. * 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 * //from w ww . j a v a 2s . c om * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ import java.io.*; public class Main { public static void deleteEmptyDirs(File dir) throws IOException { File[] files = dir.listFiles(); if (files != null) { for (int i = 0; i < files.length; i += 1) { deleteEmptyDirs(files[i]); } dir.getCanonicalFile().delete(); } } }