Here you can find the source of deleteFile(String filePath)
public static boolean deleteFile(String filePath)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static boolean deleteFile(String filePath) { File file = new File(filePath); if (!file.exists()) { return true; } else {//ww w . j a v a2 s .c o m if (file.isFile()) { return file.delete(); } else { for (File f : file.listFiles()) { deleteFile(f.getAbsolutePath()); } return file.delete(); } } } }