Here you can find the source of deleteEmptyFolders(java.io.File file)
public static boolean deleteEmptyFolders(java.io.File file)
//package com.java2s; /******************************************************************************* * Copyright (c) 2007 Red Hat, Inc./*from w ww .j a va 2 s. co m*/ * 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 ******************************************************************************/ public class Main { public static boolean deleteEmptyFolders(java.io.File file) { boolean b = true; if (file.isDirectory()) { java.io.File[] children = file.listFiles(); for (int i = 0; i < children.length; i++) b &= deleteEmptyFolders(children[i]); if (file.listFiles().length == 0) file.delete(); } return b; } }