Java tutorial
//package com.java2s; import java.io.File; public class Main { public static void deleteFile(String fileName) { File file = new File(fileName); if (file.exists()) { if (file.isDirectory()) { if (file.listFiles().length == 0) { file.delete(); } else { for (File f : file.listFiles()) { if (f.isDirectory()) { deleteFile(f.getPath()); } else { f.delete(); } } file.delete(); } } else { file.delete(); } } } }