Here you can find the source of deleteRecursive(File path)
Parameter | Description |
---|---|
path | File or Directory to be deleted |
public static boolean deleteRecursive(File path)
//package com.java2s; /*/* w w w .j a va 2 s. c om*/ * Copyright by AGYNAMIX(R). All rights reserved. * This file is made available under the terms of the * license this product is released under. * * For details please see the license file you should have * received, or go to: * * http://www.agynamix.com * * Contributors: agynamix.com (http://www.agynamix.com) */ import java.io.File; public class Main { /** * This function will recursivly delete directories and files. * * @param path * File or Directory to be deleted * @return true indicates success. */ public static boolean deleteRecursive(File path) { if ((path.exists()) && (path.isDirectory())) { File[] files = path.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { deleteRecursive(files[i]); } else { files[i].delete(); } } } } return (path.delete()); } }