Here you can find the source of deleteFile(final File file)
Parameter | Description |
---|---|
file | file path |
public static boolean deleteFile(final File file)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { /**//from w ww . jav a 2 s . c o m * delete file or directory * * @param file * file path * @return true - if the file/directory has been deleted<br> * false otherwise */ public static boolean deleteFile(final File file) { // delete directory content recursively if (file.isDirectory()) { final File[] children = file.listFiles(); for (File child : children) { if (!deleteFile(child)) { return false; } } } // delete file/empty directory return file.delete(); } }