Here you can find the source of delete(File path)
public static boolean delete(File path)
//package com.java2s; import java.io.File; public class Main { public static boolean delete(File path) { if (null == path || !path.exists()) { return false; }//from w w w .j ava 2 s.c o m boolean delete = false; if (path.isDirectory()) { File[] files = path.listFiles(); if (null != files && files.length > 0) { for (File file : files) { delete(file); } } System.out.println("delete dir: " + path.getAbsolutePath()); delete = path.delete(); } else { System.out.println("delete file: " + path.getAbsolutePath()); delete = path.delete(); } return delete; } }