Question: Without resorting to platform dependent Runtime.Exec() calls, how does one find out how much disk space is available from Java?
Answer: Use
Java 6.
Not sure why it took so long for this bug
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4057701 - entered way back in June 1997 - to finally make it into the java api but it's here.
The
javadoc for java.io.File details the new getTotalSpace(), getFreeSpace() and getUsableSpace() methods. They've also added the ability to set the read, write and executable flags for a File in this latest version.
However with the final release of Java 6 slated for later this year what should one do in the meantime? Or what if one needs to be compatible with an earlier version of Java?
tags: java file usage