问题
Is there an cross-platform way to determine the maximum file size of the host OS in Java?
回答1:
No, maximum file size is file system dependent. (you can see a comparison here). You can figure out the file system type using a platform specific manner (for example, mount on linux).
回答2:
The largest file is surely no larger than the amount of free space, which you can get via
long FileSystemUtils.freeSpaceKb(String path)
from Apache Commons IO
On JDK 6, you can use File.getFreeSpace() to find the free space of the partition containing the file.
来源:https://stackoverflow.com/questions/2905974/java-maximum-file-size