Here you can find the source of delete(File f)
public static void delete(File f) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static void delete(File f) throws Exception { try {// ww w.j ava 2s.c o m if (f.exists()) { if (f.isDirectory()) { File[] child = f.listFiles(); for (File fc : child) { delete(fc); } } f.delete(); } f.deleteOnExit(); } catch (Exception e) { e.printStackTrace(); throw e; } } /** * delete file * * @param file * @throws Exception */ public static void delete(String file) throws Exception { try { File f = new File(file); delete(f); } catch (Exception e) { e.printStackTrace(); throw e; } } }