After some googling this appears to be a Java bug. The workaround is to call System.gc after setting the stream to null, like so:



AudioInputStream audioInputStream = null;
File f = null;...