Here you can find the source of deleteFileOrDir(File file)
Parameter | Description |
---|---|
file | The file to recursively delete. |
Parameter | Description |
---|---|
IOException | is thrown in case of IO issues. |
public static void deleteFileOrDir(File file) throws IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.IOException; public class Main { /**//from www .j av a 2 s . c o m * Utility method used to delete the profile directory when run as a * stand-alone application. * * @param file * The file to recursively delete. * @throws IOException * is thrown in case of IO issues. **/ public static void deleteFileOrDir(File file) throws IOException { if (file.isDirectory()) { for (File child : file.listFiles()) { deleteFileOrDir(child); } } if (!file.delete()) { throw new IOException("Could not remove '" + file + "'!"); } } }