• Post Reply Bookmark Topic Watch Topic
  • New Topic

finding out disk space

 
Abhinav Anand
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • 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
 
Snigdha Solanki
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this on unix:
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • 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
  • 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,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!