My Java application (which is quite a bit of code) does a lot of file operations. At one point in my application, I need to move a file from one location to another and for this I'm using the Files.move
method from JDK7.
When I try to do this, I get an error telling me that the file is in use. I know for a fact that it's some part of my code that is locking this resource.
How I force my Java application to release all locks prior to calling the function that moves/renames my file?
If this is not possible, is there an easy way to check which part of my code is locking the file? Trudging through my whole codebase to find unclosed file handles would be a nightmare considering the amount of code there is.
Thanks