I am writing a java application that needs to keep track of what
percentage of the disk it uses. It has to run on the various flavors
of UNIX and Windows.
Problem 1: Is there a Java API class that would allow the application
to know the total capacity of a particular disk?
Problem 2: Is there a Java API class that would allow the application
to know either the 'size on disk' of a file or the disk block size?
(I can get the size of a file via File.length() but that doesn't tell
me the whole story. For example, on Windows 2000, the file properties
pulldown shows the 'Size on disk' to be the 'Size' rounded up to the
next multiple of 4k. This is the number I really need. Of course, I
can derive it from the size as (((size - 1) * 4096) + 1) * 4096 -- if
the block size is always 4096. But, I'm not sure if it always is, even
on Windows 2000. Maybe it's an installation parameter. And I can't
count on it being the same on other flavors of Windows and UNIX).
/Joe