File.getFreeSpace() Not returning correct value
I use file.GetFreeSpace()
from Java's File class in my application to make sure that there is enough room before transferring files. The path is a unc path that currently has ~5TB of free space on it. However when the above code is ran, the amount of space returned is only 713998336 Bytes (~680MB).
I mapped the application to use a different unc path that had in between 100MB and a little over 1GB free (I was adding/removing files to test) and the application reported the correct amount of free space there.
UPDATE: Through much debugging, I have found the issue.
The unc path similar to this: \\domain6\test\Scratch_Folder\
where Scratch_Folder is a DFS namespace with ~5TB of free space. However when file.getFreeSpace
executes, it is returning the free space for \开发者_运维问答\domain6\test\
which only has 670MB. Why would this happen?
I found the issue! Java was returning the amount of free space in the root of the DFS, not the actual folder of the DFS (the Scratch_Folder was showing up as a shortcut). I found a different, more direct path to the folder that didn't contain the shortcut, pointed the application there instead and now it is working as expected.
Sounds like a bug in your JVM. This feature is new to Java 6, can you try Java 6 update 25. When I run this for a UNC path with 9 TB free, I see 9 TB.
精彩评论