Java tutorial
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static void deleteDirContent(File dir) { final File[] files = dir.listFiles(); if (files != null) { for (final File file : files) { if (file.isDirectory()) { deleteDirContent(file); } file.delete(); } } } public static void delete(File file) { if (!file.delete()) { throw new RuntimeException("File " + file.getAbsolutePath() + " can't be deleted."); } } }