delete temporary file in java

前端 未结 4 1474
伪装坚强ぢ
伪装坚强ぢ 2021-01-03 23:26

I\'m creating temporary file in java but i\'m unable to delete it. This is the code I have written:

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


        
4条回答
  •  我在风中等你
    2021-01-03 23:42

    There's a bug saying that if the file is open by filewriter or anything, it won't be deleted. On windows. Check if you close your file writers.

    Another workaround would be installing a ShutdownHook which would manually delete the file.

提交回复
热议问题