Here you can find the source of deleteFiles(File directory)
public static boolean deleteFiles(File directory)
//package com.java2s; /*/* w w w .j a v a 2 s.c o m*/ * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2006. * * Licensed under the Aduna BSD-style license. */ import java.io.File; public class Main { /** * Deletes all files and directories in the specified directory. Nothing * happens when the specified File is not a directory. * * @return true when all files in the specified directory were successfully * deleted, when there where no files or when the specified file was * not a directory. */ public static boolean deleteFiles(File directory) { boolean result = true; if (directory.isDirectory()) { File[] list = directory.listFiles(); for (int i = list.length; i-- > 0;) { File file = list[i]; if (file.isFile()) { result = result && file.delete(); } } } return result; } }