public static void main(String[] args) throws IOException {
File file = new File("F:");
if (file.exists()) {
prt("Total:", file.getTotalSpace());
prt("Usable:", file.getUsableSpace());
prt("Free:", file.getFreeSpace());
}
}
static void prt(String desc, long size) {
double m = size / (1024 * 1024);
double g = m / 1024;
System.out.printf("%s %.2f G / %.2f M %n", desc, g, m);
}