
Provides method to get the free space on a disk drive.
Following is the declaration for org.apache.commons.io.FileSystemUtils Class −
public class FileSystemUtils extends Object
IOTester.java
import java.io.IOException;
import org.apache.commons.io.FileSystemUtils;
public class IOTester {
public static void main(String[] args) {
try {
System.out.println("Free Space " + FileSystemUtils.freeSpaceKb("C:/") + " Bytes");
} catch(IOException e) {
System.out.println(e.getMessage());
}
}
}
It will print the following result.
Free Space 61355640 kb