Delete a file or directory when JVM terminates.
Delete a file or directory when JVM terminates.
The deleteOnExit method of file class can be used for deleting a file or directory when JVM terminates.
package io;
import java.io.File;
/**
* File class examples
*
* Contains different operations of java.io.File class.
*/
public class FileExample {
public static void main(String[] args){
File file = new File("d:\\temp\\test1.txt");
// Delete the file or directory when JVM terminates
file.deleteOnExit();
}
}
Tags: delete file, File, file class examples, File examples, java.io, java.io.File
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Leave a Reply