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.File; import java.io.IOException; public class Main { /**/*from w w w.j a v a 2 s . c om*/ * Recursively deletes file or directory. * @param file * @throws IOException */ public static void delete(File file) throws IOException { if (file.exists()) { if (file.isDirectory()) { for (File c : file.listFiles()) { delete(c); } } if (!file.delete()) { throw new IOException("Could not delete " + file.getAbsolutePath()); } } } }