File.delete() Does Not Delete File In Java

There may be cases when you call the delete() method in Java and your program does not delete the file. A case like this can  only mean that the file is still being used provided that the file exists.

Suggestions indicate that you need to close the stream that uses the file. However, if all else fails, a simple hack can be done to fix this problem.

Just call System.gc() and it should do the trick.

Related Posts Plugin for WordPress, Blogger...

Leave a Reply

Your email address will not be published. Required fields are marked *