open temp file in java

后端 未结 4 1641
执念已碎
执念已碎 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 17:43

    How about something like:

    if (!temp.delete())
    {
        // wasn't deleted for some reason, delete on exit instead
        temp.deleteOnExit();
    }
    

提交回复
热议问题