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