Here you can find the source of delete(String path)
public static void delete(String path)
//package com.java2s; /**//from w w w . java 2 s.c o m * Copyright(c) 2005 Dragonfly - created by FengChun * All Rights Reserved. * * @license: Dragonfly Common License * @date 2005-5-16 */ import java.io.File; public class Main { public static void delete(String path) { File f = new File(path); if (!f.exists()) return; if (f.isDirectory()) { if (f.listFiles().length == 0) { f.delete(); } else { File delFile[] = f.listFiles(); int i = f.listFiles().length; for (int j = 0; j < i; j++) { if (delFile[j].isDirectory()) { delete(delFile[j].getAbsolutePath()); } delFile[j].delete(); } } } else { f.delete(); } } }