Java file delete and System.gc()

前端 未结 2 1638
一个人的身影
一个人的身影 2021-01-22 10:45

In my app I\'m writing a file to store some execution info and once the execution is done I want to delete the temp file. The issue is even after file close or flush by streams

2条回答
  •  旧时难觅i
    2021-01-22 11:44

    That seems to indicate that you did not call close().

    Reason: in the begin time of java, the Object.finalize() method was used to clean up on garbage collection, and for I/O it did a close().

    Until the file is in use (not closed), the file cannot be deleted on Windows.

提交回复
热议问题