tags:

views:

96

answers:

3

Hi all,

I am looking for a nice and easy way to display the free amount of space of a specific Hard Disk inside my Java Application.

I am quite surprised that this is only implemented in java 6 thanks to the method getFreeSpace() in the File class.

Unfortunately, we are using java 5 and don't want to change that for the moment.

Is there any way to do that in java 5 ?

Thanks !

+7  A: 

Apache Commons IO provides a FilesystemUtil.freespaceKb method, which works by issuing platform-specific process commands to the Runtime. Pretty ugly underneath, no doubt, but nice and easy on the surface.

skaffman
A: 

You may use Apache org.apache.commons.io.FileSystemUtils.

Dennis Cheung
+1  A: 

Maybe this could help you :

http://commons.apache.org/io/api-release/org/apache/commons/io/FileSystemUtils.html

The current functions provided are:

* Get the free space on a drive
n00ki3