tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Commons IO > Basic > Force Delete

Force Delete 

Apache Commons IO is a java library with simple IO utilities and filters. This requires the library commons-io-2.1.jar to be in classpath. The following example shows using FileUtils.forceDelete() API. It deletes the given file or directory recursively. Throws IOException if the file or directory cannot be deleted.

File Name  :  
Author  :  Sudhakar KV
Email  :  [email protected]
package com.bethecoder.tutorials.commons_io.tests;



public class ForceDelete {

   @param args
   @throws IOException 
  public static void main(String[] argsthrows IOException {
    File file = new File("C:/");
    File directory = new File("C:/Test2");
    //Deletes this file or directory
    System.out.println("Deleted successfully");

It gives the following output,
Deleted successfully


bl  br