Here you can find the source of delete(File path)
Parameter | Description |
---|---|
path | File |
public static void delete(File path)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { /**//from w ww . j a va2s .co m * deletes files and directories * * @param path File */ public static void delete(File path) { if (path.exists()) { if (path.isDirectory()) { File files[] = path.listFiles(); for (File file : files) { //delete each file in folder delete(file); } //delete the folder path.delete(); } else { //delete file i it is not a folder path.delete(); } } } }