The Source for Java Technology Collaboration
User: Password:



Chris Adamson

Chris Adamson's Blog

Getting the free disk space

Posted by invalidname on June 03, 2005 at 07:46 PM | Comments (2)

IM's between me and Cooper a few weeks back:

Cooper: Stupid question nobody seems to know... Do you know how to find out the free space available on a filesystem from java?
Me: ah ha ha ha ha ha ha ha ha ha ha ha ha ha
Cooper: I take it you have seen that before?
Cooper: :-=
Me: I'm looking up the RFE for you
Me: suffice to say, for now, you're Runtime.exec()'ing a du and scraping stdin.
Cooper: Well, that will be a very cross platformy thing now won't it?
Me: ah ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha

Well, I guess I can take the "ha " out of my clipboard now, because the Sun bug-bot sent me an e-mail to say that Bug 4057701 (Need way to find free disk space) has been closed as fixed.

The bug report shows it as being fixed in mustang(b39), and thanks to the mustang project on java.net, you can check it out for yourself. And I literally mean you, because I'm on a Mac and thus can't build Mustang.

Still, it's a huge relief that after all this time, this embarrassing oversight/omission is finally being resolved. And by "finally", it's worth nothing that Thursday would have marked eight years to the day after the bug was filed.


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • This is a cut&paste from the javadoc :
    Three methods :
    - file.getTotalSapce()
    Returns the size of the partition named by this abstract pathname.
    - file.getFreeSpace()
    Returns the number of unallocated bytes in the partition
    named by this abstract path name.
    - file.getUsableSpace()
    Returns the number of bytes available to this virtual machine
    on the partition named by this abstract pathname. When
    possible, this method checks for write permissions and
    other operating system restrictions and will therefore
    usually provide a more accurate estimate of how much
    new data can actually be written than getFreeSpace()

    Posted by: forax on June 06, 2005 at 11:20 AM

  • Even better, check out the
    actual javadoc.

    Posted by: mreinhold on June 06, 2005 at 03:15 PM





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds