Skip to content

Tag: delete-file

Prevent and Detect Deletion of an Open File

My Java program opens a file and slowly writes to the file. When the operation is completed, the program closes the file and moves the file to its final resting place in another directory. The problem is that as the operation is running, another thread in the same Java program deletes the file. Windows will not allow the deletion of

java Cannot delete file, being used by another process

I have this code and when I execute it it says java.nio.file.FileSystemException The process cannot access the file because it is being used by another process (in sun.nio.fs.WindowsException) In the sameSha1() I have this: I want to delete the file ‘SHA1.txt’. How can I do this? Answer I guess with sameSha1 you open SHA1.txt to read it and you forget