Home Basic File Questions Questions using library methods How to get Total space, Free space and Usable space of given disk drive in Java?
Write a program in Java that prints total space, free space and usable space of given disk drive.
How to get total, free and usable space in Java?
For getting required information we need to use following methods of File class that is present in java.io.* package.
public long getTotalSpace() - Print total space.
public long getFreeSpace() - Print free space.
public long getUsableSpace() - Print usable space.
* @problem How to get disk space information in java?
Output - How to get disk space information in Java?