package com.javaniu; import java.io.File; public class FreeDiskSpace { public static void main(String[] args) { File file = new File("c:"); long totalSpace = file.getTotalSpace(); long freeSpace = file.getFreeSpace(); long usedSpace = totalSpace - freeSpace; System.out.println("总空间大小 : " + totalSpace / 1024 / 1024 / 1024 + "G"); System.out.println("剩余空间大小 : " + freeSpace / 1024 / 1024 / 1024 + "G"); System.out.println("已用空间大小 : " + usedSpace / 1024 / 1024 / 1024 + "G"); } }
最近下载更多