Here you can find the source of deleteTestDir(final File file)
static void deleteTestDir(final File file)
//package com.java2s; /*//w w w . ja va 2s .c o m * Copyright (c) 2016 Cisco Systems, Inc. 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 */ import java.io.File; public class Main { static void deleteTestDir(final File file) { if (file.isDirectory()) { File[] filesToDelete = file.listFiles(); if (filesToDelete != null) { for (File f : filesToDelete) { deleteTestDir(f); } } } if (!file.delete()) { throw new RuntimeException("Failed to clean up after test"); } } }