public class SpaceCheck {
public static void main(String[] args) {
File[] roots = File.listRoots();
for (File _file : roots) {
System.out.println(_file.getPath());
//System.out.println(_file.getName());
System.out.println("Free space = " + (_file.getFreeSpace()/(1024*1024))/1024+"G"); //显示GB大小
System.out.println("Usable space = " + _file.getUsableSpace());
System.out.println("Total space = " + _file.getTotalSpace());
System.out.println("used space = " + (_file.getTotalSpace()-_file.getFreeSpace()));
System.out.println();
}
File win = new File("C:\\WINDOWS");
System.out.println(win.getPath());
System.out.println(win.getName());
System.out.println("Free space = " + win.getFreeSpace());
System.out.println("Usable space = " + win.getUsableSpace());
System.out.println("Total space = " + win.getTotalSpace());
System.out.println();
}
}
public static void main(String[] args) {
File[] roots = File.listRoots();
for (File _file : roots) {
System.out.println(_file.getPath());
//System.out.println(_file.getName());
System.out.println("Free space = " + (_file.getFreeSpace()/(1024*1024))/1024+"G"); //显示GB大小
System.out.println("Usable space = " + _file.getUsableSpace());
System.out.println("Total space = " + _file.getTotalSpace());
System.out.println("used space = " + (_file.getTotalSpace()-_file.getFreeSpace()));
System.out.println();
}
File win = new File("C:\\WINDOWS");
System.out.println(win.getPath());
System.out.println(win.getName());
System.out.println("Free space = " + win.getFreeSpace());
System.out.println("Usable space = " + win.getUsableSpace());
System.out.println("Total space = " + win.getTotalSpace());
System.out.println();
}
}