How do I get free disk space in Java?

How do I get the size of available free disk space using Java? I have searched here and there to find out a way to do it. But I haven't found anything, not either in the Javas API doc. Have I missed something, is there really no easy way to get the free disk space in Java??

Comments

  • : How do I get the size of available free disk space using Java? I have searched here and there to find out a way to do it. But I haven't found anything, not either in the Javas API doc. Have I missed something, is there really no easy way to get the free disk space in Java??


    There's no easy way. My guess is that since JAVA strives to be as cross-platform as possible, and some embedded platforms may not have hard-drives, they chose not to implement this ability.

    So, you'll have to use the hackish runtime.exec() method (to run the DIR command and parse out the part where it gives free space), or write a native method. Using a native method wouldn't be a hack like runtime.exec() would be, but it still means that your program will only run on the platforms you provide the native method for.
  • [b][red]This message was edited by miklo at 2004-6-15 8:9:37[/red][/b][hr]
    : : How do I get the size of available free disk space using Java? I have searched here and there to find out a way to do it. But I haven't found anything, not either in the Javas API doc. Have I missed something, is there really no easy way to get the free disk space in Java??
    :
    :
    : There's no easy way. My guess is that since JAVA strives to be as cross-platform as possible, and some embedded platforms may not have hard-drives, they chose not to implement this ability.
    :
    : So, you'll have to use the hackish runtime.exec() method (to run the DIR command and parse out the part where it gives free space), or write a native method. Using a native method wouldn't be a hack like runtime.exec() would be, but it still means that your program will only run on the platforms you provide the native method for.
    :

    Ok, so the way is to do an own hack, alright. Thank's a lot...



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion