Here you can find the source of deleteFile(File file)
public static void deleteFile(File file) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; public class Main { public static void deleteFile(File file) throws IOException { if (file != null) { for (File childFile : file.listFiles()) { if (childFile.isDirectory()) { deleteFile(childFile); } else { if (!childFile.delete()) { throw new IOException(); }// ww w. ja v a2 s . c o m } } if (!file.delete()) { throw new IOException(); } } } }