天天看點

Java獲得磁盤盤符,并且分析電腦各個盤符中的大小

package cn.edu.hactcm;

import java.io.file;

public class spacechecker {

  public static void main(string[] args) {

    file[] roots = file.listroots();

    for (int i = 0; i < roots.length; i++) {

      system.out.println(roots[i]);

      system.out.println("free space = " + roots[i].getfreespace());

      system.out.println("usable space = " + roots[i].getusablespace());

      system.out.println("total space = " + roots[i].gettotalspace());

      system.out.println();

    }

  }

}