delete a particular file or directory from filesystem - Java File Path IO

Java examples for File Path IO:Directory Delete

Description

delete a particular file or directory from filesystem

Demo Code


import java.io.*;
 
public class Main {
 
  public static void main(String[] args) {
    File file = new File("C://Folder/DeleteDemo.txt");
   //w  w  w  .  j  a  v  a  2s . c om
     boolean blnDeleted = file.delete();
   
     System.out.println("Was file deleted ? : " + blnDeleted);
   
  }
}

Result


Related Tutorials