Here you can find the source of deleteFileOrFolder(File fileOrFolder)
fileOrFolder
.
Parameter | Description |
---|---|
fileOrFolder | The file or folder to delete. |
public static void deleteFileOrFolder(File fileOrFolder)
//package com.java2s; /******************************************************************* * Copyright (c) 2006-2013, Cloudsmith Inc. * The code, documentation and other materials contained herein * are the sole and exclusive property of Cloudsmith Inc. and may * not be disclosed, used, modified, copied or distributed without * prior written consent or license from Cloudsmith Inc. ******************************************************************/ import java.io.File; public class Main { /**/* w w w . j av a 2 s. co m*/ * Delete the file or folder given in <code>fileOrFolder</code>. A folder * will be cleaned out (recursively) before it is deleted. * * @param fileOrFolder * The file or folder to delete. */ public static void deleteFileOrFolder(File fileOrFolder) { File[] files = fileOrFolder.listFiles(); if (files != null) { int idx = files.length; while (--idx >= 0) deleteFileOrFolder(files[idx]); } fileOrFolder.delete(); } }