我能夠獲得可用磁盤空間。我將如何獲得總磁盤空間?如何在Java中使用Linux獲得總磁盤空間?
我的代碼是:
import java.io.IOException;
import org.apache.commons.io.FileSystemUtils;
public class DiskSpace {
public static void main(String[] args) {
try {
//calculate free disk space
double freeDiskSpace = FileSystemUtils.freeSpaceKb(args[0]);
System.out.println(args[0]);
//convert the number into gigabyte
double freeDiskSpaceGB = freeDiskSpace/1024/1024;
System.out.println("Free Disk Space (GB):" + freeDiskSpaceGB);
} catch (IOException e) {
e.printStackTrace();
}
}
}
FileSystemUtils
沒有對磁盤的總空間的方法???
尼爾默爾我怎麼會得到特定驅動器的磁盤空間? – user1237231 2012-02-28 07:14:33
表示文件夾像「根」 – user1237231 2012-02-28 07:14:42
使用'新的文件(「/根」)' – 2012-02-28 07:39:57