小编use*_*231的帖子

如何使用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();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

FileSystemUtils没有磁盘总空间的方法??? 希望你的回复

提前致谢

java linux apache jsp

5
推荐指数
2
解决办法
8198
查看次数

标签 统计

apache ×1

java ×1

jsp ×1

linux ×1