Here you can find the source of delete(File f)
Parameter | Description |
---|---|
f | the file/directory to delete. |
public static boolean delete(File f)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { /**//from w w w .j ava 2 s.co m * Deletes the file/directory recursively and quietly. It does not throw exceptions if the deletion fails. Instead, * it returns false. * * @param f * the file/directory to delete. * @return */ public static boolean delete(File f) { if (f == null) { return false; } // if the file is a directory, delete the contents first. if (f.exists()) { if (f.isDirectory()) { for (File ff : f.listFiles()) { if (ff.isDirectory()) { delete(ff); } else { try { ff.delete(); } catch (Exception e) { return false; } } } } } // delete the file try { return f.delete(); } catch (Exception e) { return false; } } }