Here you can find the source of deleteAllFile(String folderPath)
public static boolean deleteAllFile(String folderPath) throws IOException
//package com.java2s; /**/*from w ww . java 2 s . c om*/ * Project: isor * * File Created at 2013-7-8 * $Id$ * * Copyright 2008 Shensuoyao.com Corporation Limited. * All rights reserved. * * This software is the confidential and proprietary information of * Shensuoyao Company. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Shensuoyao.com. */ import java.io.File; import java.io.IOException; public class Main { public static boolean deleteAllFile(String folderPath) throws IOException { boolean bool = false; File file = new File(folderPath); if (!file.exists()) return false; if (!file.isDirectory()) return false; String[] tempList = file.list(); File temp = null; for (int i = 0; i < tempList.length; i++) { if (folderPath.endsWith(File.separator)) { temp = new File(folderPath + tempList[i]); } else { temp = new File(folderPath + File.separator + tempList[i]); } if (temp.isFile()) temp.delete(); } return bool; } }