I tried with File getFreeSpace() also which returns me 0. Is there any other way to do this?
Asked
Active
Viewed 2,003 times
4 Answers
0
try {
double freeDiskSpace = org.apache.commons.io.FileSystemUtils.freeSpaceKb("/volume");
double freeDiskSpaceGB = freeDiskSpace / 1024 / 1024;
System.out.println("Free Disk Space (GB):" + freeDiskSpaceGB);
} catch (IOException e) {
e.printStackTrace();
}

jmj
- 237,923
- 42
- 401
- 438
0
public long getTotalSpace();
public long getFreeSpace();
public long getUsableSpace();
Each of these methods returns the requested size, in bytes, of the partition represented by the java.io.File or 0L if a partition cannot be obtained from the File object. Can you report your code?

mauretto
- 3,183
- 3
- 27
- 28