Java tutorial
//package com.java2s; import java.io.File; public class Main { public static void deleteFile(String filePath) { File file = new File(filePath); if (file.exists()) { if (file.isDirectory()) { File[] files = file.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { deleteFile(files[i].getPath()); } else { files[i].delete(); } } } file.delete(); } } }