Here you can find the source of deleteFiles(File dir)
private static void deleteFiles(File dir)
//package com.java2s; /*/* w ww . java 2 s.c o m*/ * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. * * This is free software; you can redistribute it and/or modify it * under the terms of the JBPM BPEL PUBLIC LICENSE AGREEMENT as * published by JBoss Inc.; either version 1.0 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ import java.io.File; public class Main { private static void deleteFiles(File dir) { File[] files = dir.listFiles(); if (files == null) return; // I/O error // delete files in the directory for (int i = 0; i < files.length; i++) { File file = files[i]; // delete any child files if (file.isDirectory()) deleteFiles(file); file.delete(); } } }