Commons Io 简明教程
Apache Commons IO - FileSystemUtils
FileSystemUtils 提供获取磁盘驱动器上可用空间的方法。
FileSystemUtils provide method to get the free space on a disk drive.
Class Declaration
下列是 org.apache.commons.io.FileSystemUtils 类的声明 −
Following is the declaration for org.apache.commons.io.FileSystemUtils Class −
public class FileSystemUtils
extends Object
Example of FileSystemUtils Class
下面是 FileSystemUtils 类的一个示例 −
Given below is the example of FileSystemUtils Class −
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());
}
}
}