Here you can find the source of deleteFileOrDirectory(String path)
public static void deleteFileOrDirectory(String path)
//package com.java2s; import java.io.File; public class Main { public static void deleteFileOrDirectory(String path) { deleteFileOrDirectory(new File(path)); }/*from w w w. java 2s .c o m*/ public static void deleteFileOrDirectory(File file) { if (!file.exists()) return; if (!file.isDirectory()) { file.delete(); return; } File directory = file; File[] children = directory.listFiles(); for (File child : children) { if (child.isDirectory()) deleteFileOrDirectory(child); else child.delete(); } directory.delete(); } }