51,408
社区成员
发帖
与我相关
我的任务
分享
public static void DiskInfos() {
File[] roots = File.listRoots();// 获取分区信息
for (File file : roots) {
System.out.println(file.getPath() + "盘使用情况:");
System.out.print("已使用 = " + file.getUsableSpace() / 1024d / 1024d/ 1024d + "G, ");
System.out.print("还剩 = " + (file.getTotalSpace()-file.getUsableSpace()) / 1024d / 1024d /1024d+ "G, ");
System.out.println("总容量 = " + file.getTotalSpace() / 1024d / 1024d / 1024d + "G");
System.out.println();
}
}