Portable way of finding total disk size in Java (pre java 6)

Posted by Wouter Lievens on Stack Overflow See other posts from Stack Overflow or by Wouter Lievens
Published on 2009-07-15T10:39:05Z Indexed on 2010/05/09 4:48 UTC
Read the original article Hit count: 280

Filed under:
|

I need to find the total size of a drive in Java 5 (or 1.5, whatever). I know that Java 6 has a new method in java.io.File, but I need it to work in Java 5.

Apache Commons IO has org.apache.commons.io.FileSystemUtils to provide the free disk space, but not the total disk space.

I realize this is OS dependant and will need to depend on messy command line invocation. I'm fine with it working on "most" systems, i.e. windows/linux/macosx. Preferably I'd like to use an existing library rather than write my own variants.

Any thoughts? Thanks.

© Stack Overflow or respective owner

Related posts about java

Related posts about disk-size