title: Java keeps lock on files for no apparent reason
body: <p>Despite closing streams in finally clauses I seem to constantly run into cleaning up problems when using Java. File.delete() fails to delete files, Windows Explorer fails too. Running System.gc() helps sometimes but nothing short of terminating the VM helps consistently and that is not an option.</p>
  
  <p>Does anyone have any other ideas I could try? I use Java 1.6 on Windows XP.</p>
  
  <p>UPDATE: FLAC code sample removed, the code worked if I isolated it.</p>
  
  <p>UPDATE: 
  More info, this happens in Apache Tomcat, Commons FileUpload is used to upload the file and could be the culprit, also I use Runtime.exec() to execute LAME in a separate process to encode the file, but that seems unlikely to cause this since ProcessExplorer clearly indicates that java.exe has a RW lock on the file and LAME terminates fine.</p>
  
  <p>UPDATE: I am working with the assumption that there is a missing close() or a close() that does not get called somewhere in my code or external library. I just can't find it!</p>