系统磁盘:File file = new File(“c:/”)
当前磁盘:File file = new File("/");
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");