Here you can find the source of clearFolderContent(String folderName)
public static void clearFolderContent(String folderName)
//package com.java2s; import java.io.File; public class Main { public static void clearFolderContent(String folderName) { File folder = new File(folderName); File[] files = folder.listFiles(); if (files != null) { //some JVMs return null for empty dirs for (File f : files) { if (f.isDirectory()) { clearFolderContent(f.getAbsolutePath()); } else { f.delete();// w w w. j ava 2s . c om } } } // folder.delete(); } }