I am working on a sc2replay syntax analysis tool. I create it on top of MPQLIB http://code.google.com/p/mpqlib/
Unfortunately, the tool uses file channels to read bzip files, and uses map(MapMode.READ_ONLY, hashtablePosition, hashTableSize);
After calling this function, closing the file channel does not free the file in the process. To be specific, I cannot rename / move the file.
The problem occurs in Java 7, and it works fine in Java 6.
Here is a simple snippet of code to replicate it:
FileInputStream f = new FileInputStream("test.SC2Replay"); FileChannel fc = f.getChannel(); fc.map(MapMode.READ_ONLY, 0,1); fc.close(); new File("test.SC2Replay").renameTo(new File("test1.SC2Replay"));
Commenting fc.map will allow you to rename the file.
PS from here Should I close the FileChannel?
It states that you do not need to close both the file and the file, because the close will be closed. I also tried closing either or both, and still did not work.
Is there a workaround when renaming a file after reading data using FileChannel.map in Java 7, because each of them seems to have Java 7 currently?
source share