Java writing to a deleted file

后端 未结 3 1987
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-04 08:16

I\'m using FileWriter to write to a file and noticed that even after I have deleted the file (out of process) the FileWriter does not throw any exception.

Is this no

3条回答
  •  [愿得一人]
    2021-01-04 08:25

    A file can appear in more than one place (with hard links) Deleting a file removes one of the hard links (possibly the only) If there is a link somewhere else, the file is still accessible.

    Files which are deleted, but open continue to take up disk space and if large enough can mean your space used and the size of all the files you can find on your disk is different.

    BTW: You can read/write the contents of an open file (deleted or not) if you look in /proc/{pid}/fd/{fid}

提交回复
热议问题