Is there an cross-platform way to determine the maximum file size of the host OS in Java?
+1
A:
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.
mdma
2010-05-25 15:23:23
This is untrue. There are (legacy) filesystems which can't create files as large as the entire disk. FAT32 for example has a file size limitation of 4GB. NTFS (and most other 64bits file systems) in turn have a theoretical limit of 16EB, but the practical limit is much lesser as well, 2TB. Nowadays disks/array-of-disks are easily that big.
BalusC
2010-05-25 15:31:22
d'oh of course. My bad. Rephrased the opening paragraph.
mdma
2010-05-25 15:34:00
Might even be possible to create files greater than free space on compressing file systems...
Brian Knoblauch
2010-10-04 20:21:56