How to delete temporary files using Java


import java.io.File;
import java.io.IOException;

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

try{

//create a temp file
File temp = File.createTempFile("tempfile", ".tmp");

//delete temporary file when the program is exited
temp.deleteOnExit();

//delete immediate
//temp.delete();

}catch(IOException e){

e.printStackTrace();

}

}
}

 

SHARE

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment