HOME      BLOG       FORUMS      CONTACT       ABOUT

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();
	}
}

Share

Tags: , , , , ,


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.

AddThis Social Bookmark Button

Leave a Reply