• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

finding out disk space

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
Is there any way besides JNI to find out the free disk space and total disk capacity through java programming.
Any suggetion will be appreciated.
Thanks,
Vishal
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this on unix:
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is one of those portability questions.
You have to remember that Java runs on platforms as diverse as mobile phones and mainframes. Many of these platforms have no concept of "disk space". Others might require you to decide whether to include network disk resources, removeable media, compression schemes and so on, before being able to consider an answer.
The answer given by the previous poster might work on many flavours of Unix, Linux etc., but there's no guarantee that "df" will be available on embedded Linux systems, and it's very unlikely to be present on Windows, Acorn RiscOS, and the hundreds of other Java platforms.
Can we step back from the problem, and consider what you need this information for? What's the user benefit that you are trying to provide by doing this? Maybe we can help find a more portable way of doing it.
 
Abhinav Anand
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
Thanks for the great advice.
I designed this app to take backup on removable media. Right now if the disk becomes full, then my program is unable to backup file because of the disk full error thrown.
Now if I get a info in advance as to how much diskspace is available, then I can design my program to backup the given amount of data at one time and then prompt the user for another media.
I would like to know if there is any way of knowing the diskspace in a platform independent way.
Thanks,
 
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic