Here you can find the source of delete(File file)
Parameter | Description |
---|---|
file | File, directory, or other filesystem artifact to delete. |
public static boolean delete(File file)
//package com.java2s; // Licensed to the Apache Software Foundation (ASF) under one or more contributor import java.io.File; public class Main { /**//from w w w . ja v a2s . co m * Delete a file or directory. If <var>file</var> references a directory, it * recursively deletes all the directory tree. * * @param file File, directory, or other filesystem artifact to delete. * @return True if <var>file</var> was deleted, false otherwise. */ public static boolean delete(File file) { if (file.isDirectory()) { File[] entries = file.listFiles(); if (entries != null) { for (File entry : entries) { if (!delete(entry)) { return false; } } } } return file.delete(); } }