How to find how much disk space is left using Java?

diskspace, java

Solution

Have a look at the File class documentation. This is one of the new features in 1.6.

These new methods also include:

- `public long getTotalSpace()`

- `public long getFreeSpace()`

- `public long getUsableSpace()`

If you're still using 1.5 then you can use the Apache Commons IO library and its FileSystem class

Problem

How to find how much disk space is left using Java?

Original source