Here you can find the source of deleteRecursive(File file)
Deletes a directory or file <p/> Taken from http://forum.java.sun.com/thread.jspa?threadID=470197&messageID=2169110 <p/> Author: jfbriere
Parameter | Description |
---|---|
file | a parameter |
public static void deleteRecursive(File file)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { /**// w ww . j a va 2 s. c o m * Deletes a directory or file * <p/> * Taken from * http://forum.java.sun.com/thread.jspa?threadID=470197&messageID=2169110 * <p/> * Author: jfbriere * * @param file */ public static void deleteRecursive(File file) { if (file.isDirectory()) { File[] fileArray = file.listFiles(); if (fileArray != null) { for (File aFileArray : fileArray) { deleteRecursive(aFileArray); } } } if (!file.delete()) { System.err.println("Cannot delete file"); } } }