Here you can find the source of deleteFolderContents(File folder)
public static void deleteFolderContents(File folder)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static void deleteFolderContents(File folder) { File[] files = folder.listFiles(); if (files != null) for (File f : files) { if (f.isDirectory()) { deleteFolderContents(f); f.delete();//from w w w . java 2 s . c om } else f.delete(); } } }