Here you can find the source of deleteDirectoryIncludeContent(String folderPath)
Parameter | Description |
---|---|
folderPath | folder path |
Parameter | Description |
---|---|
IOException | an exception |
public static void deleteDirectoryIncludeContent(String folderPath) throws IOException
//package com.java2s; /**//from w w w . jav a2 s . c o m * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for * license information. */ import java.io.*; public class Main { /** * Delete directory including contents * @param folderPath folder path * @throws IOException */ public static void deleteDirectoryIncludeContent(String folderPath) throws IOException { deleteDirectoryIncludeContent(new File(folderPath)); } private static void deleteDirectoryIncludeContent(File f) throws IOException { if (f.isDirectory()) { File[] files = f.listFiles(); if (files != null) { for (File c : files) { deleteDirectoryIncludeContent(c); } } } if (!f.delete()) { throw new FileNotFoundException("Failed to delete : " + f); } } }