Here you can find the source of clearFolder(String folder)
public static void clearFolder(String folder)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static void clearFolder(String folder) { clearFolder(new File(folder)); }// ww w. jav a 2 s . c o m public static void clearFolder(File folder) { if (folder.exists()) { for (File child : folder.listFiles()) { if (child.isDirectory()) clearFolder(child); if (!child.delete()) throw new RuntimeException("Cannot delete " + child); } } } }