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