Reputation: 1855
I am copying recursively a directory, and tried with:
FileSystemUtils#copyRecursively
of SpringFileUtils#copyDirectory
of Apache CommonsSometimes I need to delete or move this directory and I cannot do that without restarting my application (I got a java.nio.file.AccessDeniedException
).
I'm testing on Windows. Even with Windows Explorer, the directory cannot be deleted. I guess my issue is inherent to Windows but I didn't found much documentation about that.
Any idea or solution?
Upvotes: 1
Views: 73
Reputation: 921
java.nio.file.AccessDeniedException
could mean that directory is currently being accessed. The fact that restarting your application solves the problem makes me think that it's actually your application uses the directory.
You can check this theory using one of the ways specified in this Super User topic. If you find that java process holds a lock on the directory then you'll need to double check your code to see why this happens.
Upvotes: 1