File.getFreeSpace() Not returning correct value

…衆ロ難τιáo~ 提交于 2019-12-23 15:30:13

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/6281580/file-getfreespace-not-returning-correct-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!