Java File delete file on JVM exit

Description

Java File delete file on JVM exit

import java.io.File;

public class Main {
  public static void main(String[] args) {

    // To delete the file immediately
    File myFile = new File("Main.txt");
    myFile.deleteOnExit();/*  w w  w  .ja  va 2 s  .co m*/
  }
}



PreviousNext

Related