How to delete a particular file or directory when Java Virtual Machine terminates - Java File Path IO

Java examples for File Path IO:Directory Delete

Description

How to delete a particular file or directory when Java Virtual Machine terminates

Demo Code

 
import java.io.*;
 
public class Main {
 
  public static void main(String[] args) {
    File file = new File("C://Folder//DeleteDemo.txt");
    file.deleteOnExit();//  w  w w.ja v a  2  s . c o  m
  }
}

Related Tutorials