posted 22 years ago
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.