Here you can find the source of deleteEmptyChildren(java.io.File file)
public static boolean deleteEmptyChildren(java.io.File file)
//package com.java2s; /******************************************************************************* * Copyright (c) 2007 Red Hat, Inc./* w w w. ja v a2 s. c o 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 deleteEmptyChildren(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]); } return b; } 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; } }