open temp file in java

后端 未结 4 1639
执念已碎
执念已碎 2020-12-10 17:15

I\'m writing string to temporary file (temp.txt) and I want that file should open after clicking button of my awt window it should delete when I close that file

4条回答
  •  春和景丽
    2020-12-10 18:01

    A file created by:

    File temp = File.createTempFile("temp",".txt");
    

    Will not be deleted, see javadoc, you have to call

    temp.deleteOnExit();
    

    so the JVM will delete the file on exit...

提交回复
热议问题