Here you can find the source of deleteFiles(String filePath)
public static boolean deleteFiles(String filePath) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; public class Main { public static boolean deleteFiles(String filePath) throws IOException { File f = new File(filePath); if (!f.exists()) { return true; }//from ww w . j a v a 2 s .c o m if (f.isDirectory()) { File[] files = f.listFiles(); if (files != null) { for (int i = 0, len = files.length; i < len; i++) { if (files[i].isFile()) { files[i].delete(); } else { deleteFiles(files[i].getAbsolutePath()); } } } } return f.delete(); } }