Java tutorial
//package com.java2s; import java.io.File; public class Main { public static void deleteFile(File file) { if (file.isFile()) { file.delete(); return; } if (file.isDirectory()) { File[] childFile = file.listFiles(); if (childFile == null || childFile.length == 0) { file.delete(); return; } for (File f : childFile) { deleteFile(f); } file.delete(); } } }