Drive Information
Obtain the drive information from File in the Java.io package.
Example:
import Java.io.File;
import Java.io.FilenameFilter;
public class Disk{
public static void main(String[] args)
{
File[] files = File. listRoots();
for(File file:files) {
// Obtains the drive space.
System. out.println (file+"TotalSpace: " +file.getTotalSpace() /102
4/1024/1024+"G");
// Obtains the available drive space.
System. out.println (file+"UsableSpace: " +file.getUsableSpace()
/1024/1024/1024+"G");
// Obtains the free drive space.
System. out.println (file+"FreeSpace: " +file.getFreeSpace() /10
24/1024/1024+"G");
}
}
Parent topic: Java