Here you can find the source of clearDir(File dir)
private static void clearDir(File dir)
//package com.java2s; /*/*from ww w .j a v a 2s. c o m*/ * Copyright (C) 2016 Sebastian Hjelm * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. */ import java.io.File; public class Main { private static void clearDir(File dir) { for (File f : dir.listFiles()) { if (f.isDirectory()) { clearDir(f); } f.delete(); } } }