Here you can find the source of deleteAllFile(String path)
Parameter | Description |
---|---|
path | a parameter |
public static boolean deleteAllFile(String path)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { /**/*w w w . j ava 2 s. c o m*/ * Delete all files * * @param path * @return */ public static boolean deleteAllFile(String path) { boolean success = true; File file = new File(path); if (!file.exists()) { success = false; } if (!file.isDirectory()) { success = false; } if (success) { String[] tempList = file.list(); File temp = null; for (int i = 0; i < tempList.length; i++) { if (path.endsWith(File.separator)) { temp = new File(path + tempList[i]); } else { temp = new File(path + File.separator + tempList[i]); } if (temp.isFile()) { success &= temp.delete(); } } } return success; } }