Here you can find the source of delete(File file)
Parameter | Description |
---|---|
file | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static void delete(File file) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { /**/* ww w. jav a2s . com*/ * Deletes the given File or directory recursively. * @param file * @throws IOException */ public static void delete(File file) throws IOException { if (file.isDirectory()) { String[] files = file.list(); if (files.length == 0) file.delete(); else { for (String temp : files) delete(new File(file, temp)); if (file.list().length == 0) file.delete(); } } else file.delete(); } }